-
Notifications
You must be signed in to change notification settings - Fork 148
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
Help with unions of complex types? #239
Comments
Oh, interesting. It seems like it works if I do: const buf = type.toBuffer({blah: {union1: {foo: 'baz'}}}); Unfortunately this conflicts with the types generated by https://github.com/joewood/avro-typescript. Maybe a bug on their end? |
You're correct, by default you'll need to "wrap" the union's values so that no information is lost (more information here). I'm not familiar with Depending on the structure of your data, you might also be able to use logical types to resolve the ambiguity and avoid wrapping the types. This comment includes an example for how to do so, as well as a little more context. |
Appreciate the quick response! That makes sense - I'll read up on those links and ask on the avro-typescript repo if I'm still stuck. Thanks again :) |
Hello! I'm trying to implement a union type and running into an error. It seems like others are having some success (#174) so I'm probably just missing something, but any help would be much appreciated.
Code to reproduce the issue:
Error:
I've also tried wrapping the union schemas with
avro.Type.forSchema
:But this produced the same error.
Any ideas? Thanks :)
The text was updated successfully, but these errors were encountered: