-
-
Notifications
You must be signed in to change notification settings - Fork 786
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
has_flatten
rework
#2795
has_flatten
rework
#2795
Conversation
…ization Consequence: `FlattenSkipDeserializing[DenyUnknown]` - does not collect data in Field, because do not read them anyway - gets `deserialize_in_place` method - gets ability to deserialize from sequence (visit_seq method) - uses `deserialize_struct` instead of `deserialize_map`
…has_flatten()==true
…zation form Consequence: `FlattenSkipSerializing` - uses `serialize_struct` instead of `serialize_map`
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.
Thanks!
This PR makes derive(Deserialize)
ignore a flatten
attribute on fields that have skip_deserializing
, and derive(Serialize)
ignore a flatten
attribute on fields that have skip_serializing
.
I would have to think whether that is the behavior that should be intended. It means that in the case of FlattenSkipSerializing
and FlattenSkipDeserializing
(using names from the test suite), we serialize using serialize_struct
and deserialize using deserialize_map
, or serialize using serialize_map
and deserialize using deserialize_struct
.
I think some users would expect that if a type is serialized using serialize_struct
, it should be deserialized using deserialize_struct
, and if a type is serialized using serialize_map
, it should be deserialized using deserialize_map
. I am not sure how sensitive various data formats are to this.
Boundary between I think, if you explicitly skip only (de)serialization method you understand consequences. I would say that the base expectation that if field is invisible for (de)serialization it does not affects the format. |
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.
Okay — makes sense.
Thank you!
This PR removes workaround from #2794 in the first commit.
The 2nd commit unifies behaviour for all cases where flatten fields processed in the deserializer. Consequence of that commit:
FlattenSkipDeserializing[DenyUnknown]
Field
, because do not read them anywaydeserialize_in_place
methodvisit_seq
method)deserialize_struct
instead ofdeserialize_map
The 3rd commit gives understandable message when derive failed due to assertion.
The 4th commit removed dead code that here since 2018.
The last commit does the unification of
has_flatten
behaviour for the serializer side. Consequence of that commit:FlattenSkipSerializing
serialize_struct
instead ofserialize_map