[ 
https://issues.apache.org/jira/browse/THRIFT-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13228762#comment-13228762
 ] 

Jens Geyer commented on THRIFT-1528:
------------------------------------

{quote}
service User(id, optional string name, optional bool isAwesome=false)
 first call User(id=1, isAwesome=true)
 second call User(id=1, name="foo")

If the second call had to serialize the default optional value no matter what 
it would cause "foo" to no longer be awesome even thought it was originally set 
in the first call and was an optional parameter for the second call. 
{quote}

Mmmh. 
In essence this would mean, that there there will always be an (explicit or 
implicit) input value. 

If I don't overlook anything, we have two possible cases here:

# Either isAwesome is not really optional, since it always has an (explicit or 
implicit) value. 
# Or, if we value the optional higher, omitted values would never be set, the 
default is obsolete.

This raises the big question, what the intention of the entire construct 
"optionally set with default" would be? What is the expected behaviour, 
exactly? Are there any use cases for this combination?


                
> Iconsistency 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
>            Priority: Minor
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to