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

Optional added back to proto3 #214

Closed
tsloughter opened this issue Jan 13, 2022 · 3 comments
Closed

Optional added back to proto3 #214

tsloughter opened this issue Jan 13, 2022 · 3 comments

Comments

@tsloughter
Copy link
Contributor

optional was added back to proto3 protocolbuffers/protobuf#8959

I think this means if a field is marked optional now that even in proto3 it should be undefined instead of the default?

@tomas-abrahamsson
Copy link
Owner

tomas-abrahamsson commented Jan 13, 2022

Yes, that seems right. I think this is what gpb does as well, or did you find some situation where it is wrong?

syntax='proto3';
message m {optional uint32 f = 1;}
1> issue214:decode_msg(<<>>, m).
{m,undefined}

Edit: support for optional in proto3 was added to gpb in 4.13.0

@tsloughter
Copy link
Contributor Author

Oh, hah, thanks, I should have tried first but instead based it on my earlier usage (I guess before 4.13) and misreading the README -- your README is actually pretty clear now that I reread it, I guess my eyes just glazed over after reading docs all over about whether proto3 really added optional back or not :)

@tomas-abrahamsson
Copy link
Owner

No probs :)

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