[ https://issues.apache.org/jira/browse/THRIFT-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227326#comment-13227326 ]
Diwaker Gupta commented on THRIFT-1528: --------------------------------------- bq. From my perspective, its insane to have a field have a value and not to serialize it. In fact, the whole "isset" thing in Java is just a hack around the fact that you can't have null primitives. I would vote for standardizing on default values being considered set at object creation. +1 for Bryan's suggestion. In fact, my first patch for THRIFT-1394 did precisely this for C++. I'm happy to provide patches for at least C++ and Java so we _always_ serialize optional fields with defaults specified, even if they were never explicitly set. bq. I would prefer to go with nullable types across the board as well, but since this currently is not an option for primitives I think we need to keep isset for those types for now. Jake: there are nullable boxed types for most Java primitives (Int, Long, Boolean etc). If the Thrift compiler uses those, then we could have nullable types across the board right? > 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