julianpeeters / avrohugger

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

An enum identifier named "package" is not rendered as a backtick quoted literal identifier, as is done for "type" #185

Closed rsitze-mmai closed 11 months ago

rsitze-mmai commented 11 months ago

The expectation is that the code gen renders `package` (back-tick quoted) as it does for `type`.

There may be other Scala reserved words that are not rendered/protected.

julianpeeters commented 11 months ago

Thanks for the report,

I wonder how type works but package does not: https://github.com/julianpeeters/avrohugger/blob/main/avrohugger-core/src/main/scala/format/FieldRenamer.scala#L6

I don't have an ETA for investigating further, but if you'd like you can provide a minimized example schema, and someone on the extended avrohugger team might be able to provide an answer or a fix.

rsitze-mmai commented 11 months ago

I've been conflating generated code for Java enums (which are java code, of course) with other Scala based artifacts. back-tick quoting won't work for Java. This isn't a bug.