-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support proto3 default value for enums #30
Comments
Digging into this more, looking at what the tutorial does here: https://clojusc.github.io/protobuf/current/1050-tutorial.html If you walk through the setup, have imported the example classes (and inner classes), you can do this: [protobuf.dev] λ=> (protobuf/create AddressBookProtos$Person$PhoneNumber {:number "1"}) Which gives this: {:number "1", :type :home} As you can see, the default is added for the enum value. I'll check your example code again next ... |
Okay, so more details: the tutorial is proto2; your example is proto3. In the tutorial, the default value to use is indicated by the line In proto3, the default for enums is specified by the rule "For enums, the default value is the first defined enum value, which must be 0." The Java lib supports proto3, so the Clojure one can too. This actually isn't a bug, but a missing feature. I'll update the ticket. |
I've added this ticket to a new epic ticket for providing full support for proto3. |
Thanks for the project, really useful and overall nice to work with.
I have noticed a bug regarding default values. For an enum, if it's set to a default value, then it will not show up in the clojure structure, and when deserializing it, the resulting object will not have any value for the enum.
I have created a simple test case exhibiting the problem at https://github.com/geekingfrog/clojure-protobuf-bug-default-enum
There is a java reference which shows the correct behavior, and a simple clojure file to compare.
The text was updated successfully, but these errors were encountered: