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

oneof with enum : which_one_of returns the wrong value when enum is the first field #63

Open
boukeversteegh opened this issue May 24, 2020 · 0 comments
Labels
bug Something isn't working has test Has a (xfail) test that verifies the bugfix or feature high priority medium Medium effort issue, can fit in a single PR
Projects
Milestone

Comments

@boukeversteegh
Copy link
Collaborator

boukeversteegh commented May 24, 2020

See commit boukeversteegh@71737cf

test case oneof_enum

boukeversteegh added a commit to boukeversteegh/python-betterproto that referenced this issue May 24, 2020
@nat-n nat-n added the bug Something isn't working label May 24, 2020
@boukeversteegh boukeversteegh added this to To do in Betterproto May 25, 2020
@boukeversteegh boukeversteegh moved this from To do to Backlog in Betterproto May 25, 2020
@boukeversteegh boukeversteegh added the has test Has a (xfail) test that verifies the bugfix or feature label May 25, 2020
@boukeversteegh boukeversteegh added the medium Medium effort issue, can fit in a single PR label May 25, 2020
@boukeversteegh boukeversteegh added this to the Better Fields milestone May 25, 2020
boukeversteegh pushed a commit that referenced this issue Jul 25, 2020
#110)

* Serialize default values in oneofs when calling to_dict() or to_json()

This change is consistent with the official protobuf implementation. If
a default value is set when using a oneof, and then a message is
translated from message -> JSON -> message, the default value is kept in
tact. Also, if no default value is set, they remain null.

* Some cleanup + testing for nested messages with oneofs

* Cleanup oneof_enum test cases, they should be fixed

This _should_ address:
#63

* Include default value oneof fields when serializing to bytes

This will cause oneof fields with default values to explicitly be sent
to clients. Note that does not mean that all fields are serialized and
sent to clients, just those that _could_ be null and are not.

* Remove assignment when populating a sub-message within a proto

Also, move setattr out one indentation level

* Properly transform proto with empty string in oneof to bytes

Also, updated tests to ensure that which_one_of picks up the set field

* Formatting betterproto/__init__.py

* Adding test cases demonstrating equivalent behaviour with google impl

* Removing a temporary file I made locally

* Adding some clarifying comments

* Fixing tests for python38
Gobot1234 pushed a commit to Gobot1234/python-betterproto that referenced this issue Aug 24, 2020
danielgtaylor#110)

* Serialize default values in oneofs when calling to_dict() or to_json()

This change is consistent with the official protobuf implementation. If
a default value is set when using a oneof, and then a message is
translated from message -> JSON -> message, the default value is kept in
tact. Also, if no default value is set, they remain null.

* Some cleanup + testing for nested messages with oneofs

* Cleanup oneof_enum test cases, they should be fixed

This _should_ address:
danielgtaylor#63

* Include default value oneof fields when serializing to bytes

This will cause oneof fields with default values to explicitly be sent
to clients. Note that does not mean that all fields are serialized and
sent to clients, just those that _could_ be null and are not.

* Remove assignment when populating a sub-message within a proto

Also, move setattr out one indentation level

* Properly transform proto with empty string in oneof to bytes

Also, updated tests to ensure that which_one_of picks up the set field

* Formatting betterproto/__init__.py

* Adding test cases demonstrating equivalent behaviour with google impl

* Removing a temporary file I made locally

* Adding some clarifying comments

* Fixing tests for python38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has test Has a (xfail) test that verifies the bugfix or feature high priority medium Medium effort issue, can fit in a single PR
Projects
Betterproto
  
Backlog
Development

No branches or pull requests

2 participants