Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case class generation issue with union of only one type #138

Open
joelvim opened this issue Jul 21, 2020 · 0 comments
Open

Case class generation issue with union of only one type #138

joelvim opened this issue Jul 21, 2020 · 0 comments

Comments

@joelvim
Copy link

joelvim commented Jul 21, 2020

The default AvroScalaTypes union value is OptionEitherShapelessCoproduct, and when the schema has a union with only one type (["long"] for instance) the code generated is Long (in standard mode) and the union notion is lost. It creates an inconsistency with avro4s schema inference.

An example:
Avro schema

{
  "type":"record",
  "name":"TestData",
  "namespace":"my.namespace",
  "fields":[
    {"name":"longValue","type":"long"},
    {"name":"unionValue","type":["long"]},
    {"name":"stringValue","type":"string"}
  ]
}

Generated case class (the union type is lost)

final case class TestData(longValue: Long, unionValue: Long, stringValue: String)

Expected generated code (at least one possibility)

final case class TestData(longValue: Long, unionValue: Long :+: CNil, stringValue: String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant