julianpeeters / avrohugger

Generate Scala case class definitions from Avro schemas
Apache License 2.0
201 stars 120 forks source link

Compilation fails for reserved keyword unit #163

Closed Edefritz closed 1 year ago

Edefritz commented 1 year ago

Hi and thanks so much for providing this library!

My team has been using avrohugger for a long time on several projects, but recently we stumbled upon an AVRO schema (which is out of our control), that uses "unit" as a property.

Avrohugger fails to compile the schema to a case class with this error message.

[error]  found   : Unit (in scala) 
[error]  required: Unit (in {my_namespace}) 
[error]     ()
[error]     ^
[info] Unit <: {my_namespace}?
[info] false
[error] four errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed 17 Jan 2023, 20:14:08

It seems that our property clashes with the Scala Unit type.

I think already figured out that unit seems to be missing in the set of reserved keywords that are escaped using backticks and I'd be happy to provide a pull-request later.

julianpeeters commented 1 year ago

Hi @Edefritz , if it's still relevant, ismailBennamer may have provided a fix for your issue in this last release: avrohugger 1.4.0 and sbt-avrohugger-2.4.0

if not, feel free to reopen whenever