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

nullable, optional fields and has_ #49

Closed
mkevac opened this issue May 5, 2015 · 3 comments
Closed

nullable, optional fields and has_ #49

mkevac opened this issue May 5, 2015 · 3 comments

Comments

@mkevac
Copy link

mkevac commented May 5, 2015

When setting nullable = false for a field, we can't say whether optional field is set or not. But we could generate additional field has_<field_name> bool that says whether field is set or not.

@awalterschulze
Copy link
Member

Yes that is true.
nullable = false is not for you if you need to know if the field was set of not.
I tend to not use nullable=false for those respective fields.
having a has_fieldname bool for each field, would also require a setter api, which is not very goey.
You could look at https://github.com/dropbox/goprotoc I know they have a setter api.
Also note that proto3 does not allow you to see if a field has been set of not. They recommend declaring another bool flag field for each of those "optional" fields.
I hope some of this helps, otherwise please reopen the issue.

@mkevac
Copy link
Author

mkevac commented May 5, 2015

Well, nullable = true is not for Go, because GC.
proto3 is very different protocol and I don't think we at Badoo will move to it. We will probably stick to proto2 for a time being.

But I understand your reluctance for adding setters.

@awalterschulze
Copy link
Member

Do you think you would like to use setters?
Because then there is at least two usecases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants