Closed chupaty closed 1 year ago
I think the reason for the current implementation is the following text from the spec: Thus, for unions containing “null”, the “null” is usually listed first, since the default value of such unions is typically null.
But I agree that it could be improved to support your use case. And the spec says usually
, not mandatory
.
I will send a PR!
This crate will make the conservative approach of using "null" only in first position as otherwise things get really too complicated.
(Although this can be reconsidered later, when the spec is clearer, and when it's supported in apache-avro
etc)
Using the following schema:
rsgen-avro errors with:
I don't see a requirement in the avro spec about this (we do have additional requirements when we have a default value, but this doesn't apply here).