-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix/default value #255
Fix/default value #255
Conversation
I created a working example of this pull request - and it worked very smoothly :) socotecio/django-socio-grpc-example#16 Great job ! |
def message_to_dict(message, **kwargs): | ||
""" | ||
Converts a protobuf message to a dictionary. | ||
Uses the default `google.protobuf.json_format.MessageToDict` function. | ||
Adds None values for optional fields that are not set. | ||
""" | ||
|
||
kwargs.setdefault("including_default_value_fields", True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this ? I would guess it breaks non optional fields with value=default
if field.field_name in data_dict: | ||
continue | ||
# INFO - AM - 04/01/2024 - Adding default None value only for optional field that are required and allowing null or having a default value | ||
if field.allow_null or field.default in [None, empty] and field.required is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does field.default in [None, empty] and field.required is True happen ?
In _get_cardinality comes from not field.required or field.default not in [None, empty]
@markdoerr we have an issue as specified by Leni. With new method when user want to update a non optional field to the default grpc value (0 for int or "" for string) it does not update as removed from the gRPC message. Will work on that on friday but @legau told me it may not have a solution without specific user declaration. |
@markdoerr I almost finish but I need to stop for today. Already at more than 500 code of tests |
@markdoerr I did not manage to find the time to finish this today. Following my agenda I think I will not have the time to finish before holliday. |
Dear @AMontagu, |
@legau You can review again. If you have only small changes can you do it by yourself and merge to let @markdoerr use master fot its release ? |
Co-authored-by: Léni <[email protected]>
Co-authored-by: Léni <[email protected]>
072ca66
to
2716fed
Compare
FIX: #171