[
https://issues.apache.org/jira/browse/THRIFT-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13865068#comment-13865068
]
James Haggerty commented on THRIFT-1528:
----------------------------------------
Yeah, I see the ugliness of defaults set on optionals (i.e. so sometimes the
server sets its default, and sometimes the client sets its default, depending
on who's receiving). But you have this problem regardless of whether you
serialise defaults, you just flip the source of the definition (creator vs.
receiver).
It is nice for documentation, though, as it means that users can easily see
what the default behaviour is (rather than you maintaining the comment for the
field and the code separately).
> Inconsistency in optional fields between Java/C# and python
> -----------------------------------------------------------
>
> Key: THRIFT-1528
> URL: https://issues.apache.org/jira/browse/THRIFT-1528
> Project: Thrift
> Issue Type: Bug
> Components: Python - Compiler
> Affects Versions: 0.8
> Reporter: Stefan Gmeiner
> Fix For: 1.0
>
>
> If a struct contains optional fields with default values the generated python
> code serialize differently than Java or C# code.
> In Java or C# optional fields are only serialized if a field was set by the
> client. If not the field is omited during serialization. This is possible
> because C#/Java maintains for each field a 'isset'-boolean which records if a
> field was set or not.
> However the generated python code does not have such a 'isset'-structure. It
> writes every field which is not equal None. As the constructor initialize the
> optional fields with their default value, these fields are written whether
> they are set or not.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)