You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by dcelasun <gi...@git.apache.org> on 2017/05/30 11:48:40 UTC

[GitHub] thrift pull request #1281: THRIFT-3703 Unions Field Count Does Not Consider ...

GitHub user dcelasun opened a pull request:

    https://github.com/apache/thrift/pull/1281

    THRIFT-3703 Unions Field Count Does Not Consider Map/Set/List Fields

    Even though maps and slices are not pointer fields in the generated
    code, they are still nullable. Adding an extra check for map/set/list
    types fixes the generated Count* methods.
    
    Sample IDL:
    ```thrift
    union Foo{
        1: map<bool,bool> u1
        2: set<bool> u2
        3: list<bool> u3
        4: bool u4
    }
    ```
    
    Generated code before fix:
    ```go
    func (p *Foo) CountSetFieldsFoo() int {
    	count := 0
    	if p.IsSetU4() {
    		count++
    	}
    	return count
    }
    ```
    
    After fix:
    ```go
    func (p *Foo) CountSetFieldsFoo() int {
    	count := 0
    	if p.IsSetU1() {
    		count++
    	}
    	if p.IsSetU2() {
    		count++
    	}
    	if p.IsSetU3() {
    		count++
    	}
    	if p.IsSetU4() {
    		count++
    	}
    	return count
    }
    ```
    
    Fixes THRIFT-3703.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dcelasun/thrift THRIFT-3703

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/1281.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1281
    
----
commit cacfd6fd041eba27540f61a897cc5d5826126197
Author: D. Can Celasun <ca...@dcc.im>
Date:   2017-05-30T10:44:56Z

    THRIFT-3703 Unions Field Count Does Not Consider Map/Set/List Fields
    
    Even though maps and slices are not pointer fields in the generated
    code, they are still nullable. Adding an extra check for map/set/list
    types fixes the generated Count* methods.
    
    Fixes THRIFT-3703.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift issue #1281: THRIFT-3703 Unions Field Count Does Not Consider Map/Set...

Posted by dcelasun <gi...@git.apache.org>.
Github user dcelasun commented on the issue:

    https://github.com/apache/thrift/pull/1281
  
    Travis failures are unrelated to the PR, looks like problems with Java and JS. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request #1281: THRIFT-3703 Unions Field Count Does Not Consider ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/thrift/pull/1281


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---