Skip to content
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

Fix GetBSON() method usage #485

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open

Fix GetBSON() method usage #485

wants to merge 1 commit into from

Commits on Aug 31, 2017

  1. Fix GetBSON() method usage

    Original issue
    ---
    
    You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.
    
    For example, you can't create custom GetBSON() for Bar type:
    
    ```
    struct Foo {
    	a  Bar
    	b *Bar
    }
    ```
    
    Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.
    
    Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.
    
    After this change
    ---
    
    For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
    In this case `nil` value would be seariazied as `nil` BSON value.
    
    For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.
    bozaro committed Aug 31, 2017
    Configuration menu
    Copy the full SHA
    e2db153 View commit details
    Browse the repository at this point in the history