-
Notifications
You must be signed in to change notification settings - Fork 88
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
make generated 'New<Type>' functions fill in defaults for UnionNull<X> fields #143
Comments
Have you tried the newest major release? Unions with a null as the first type are now represented as nullable pointers, which should resolve this issue |
v7 solves that issue thanks :) One thing I did notice that I thought was strange is that the enum value for '0' fo null type was removed Used to be like
now it is
So my code that did
was broken, did this enum value need to be removed, since it is still possible to have a UnionNullString with a 0 UnionType Also, it would be nice if there was a method
so that when you use it can create instances using literals instead of
you can write
|
Sorry for the slow reply.
This actually isn't possible - we'll never decode this (it'll decode as a nil pointer) and if you try to encode it to Avro you'll get an error for an illegal value in the UnionType field. You should check if
Providing some convenience methods for working with unions is a good suggestion, they're historically one of the most confusing parts of the library. I'll add this when I have time. |
As an aside. I recently upgraded to v7 and like the changes to map and union VERY MUCH !. As a suggestion (which seems similar to the above), could they be cleaned up a little further when there are only 2 entries ? (i.e. it is just a nullable type). Currently it still generates a type with an enum you have to set, when it isn't needed. i.e.
And in the refering type.
Where I think this could just be
Would greatly simplify nullable types. |
example, I have a schema with many union null types since to be backwards compatible this is how they need to be added
schema
I would like to be able to do this :
but this fails with a
So I have to manually remember to add in
So this causes my code to break each time I upgrade to a new avro schema, if I forget any of these
The text was updated successfully, but these errors were encountered: