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

Support proto3 field presence feature #73

Closed
linarkou opened this issue May 29, 2020 · 6 comments
Closed

Support proto3 field presence feature #73

linarkou opened this issue May 29, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@linarkou
Copy link

linarkou commented May 29, 2020

Hi!
Protobuf released new feature https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md that allows nulls for primitive types.
So there is no need in wrappers.
What about support this?

Also see the implementation docs at https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/implementing_proto3_presence.md

@linarkou linarkou changed the title Experimental "field presence" feature in protobuf 3.12.0 Experimental "explicit field presence" feature in protobuf 3.12.0 May 29, 2020
@linarkou linarkou closed this as completed Jun 5, 2020
@stephenh stephenh reopened this Jun 6, 2020
@stephenh stephenh changed the title Experimental "explicit field presence" feature in protobuf 3.12.0 Support "explicit field presence" feature in protobuf 3.12.0 Jun 6, 2020
@stephenh
Copy link
Owner

stephenh commented Jun 6, 2020

Wow @linarkou sorry for taking awhile to get back to you, but I'd heard not about this. This seems like a huge deal. proto3 missing optional was a huge complaint I had with it...

I'm still reading the impl details, i.e. about the synthetic oneof approach, but, yes, I think its really reasonable for ts-proto to support this "new" :-) optional.

@stephenh stephenh changed the title Support "explicit field presence" feature in protobuf 3.12.0 Support "explicit field presence" feature Jun 6, 2020
@stephenh
Copy link
Owner

stephenh commented Jun 6, 2020

@linarkou let me know if you're interesting in hacking on this, would be great to have a PR. Otherwise it's a great feature, so I'll get around to hacking on it at some point.

@stephenh stephenh changed the title Support "explicit field presence" feature Support proto3 optional feature Jun 6, 2020
@linarkou
Copy link
Author

linarkou commented Jul 2, 2020

@stephenh I'm new in typescript, so I think I can't help you, sorry(

@cliedeman
Copy link
Contributor

This probably needs protobufjs support. protobufjs/protobuf.js#1406

@stephenh
Copy link
Owner

stephenh commented Jul 3, 2020

@cliedeman I could be wrong, but fwiw I don't think so. ts-proto calls the lower-level reader/write APIs in protobuf.js's Reader/Writer classes but otherwise drives the encode/decode process itself, and from my initial read of the spec where "field presence is something something oneofs" (...would have to read it again...) I'm ~80% sure just some changes to ts-proto's generated encode/decode methods could handle this.

@stephenh stephenh changed the title Support proto3 optional feature Support proto3 field presence feature Aug 21, 2020
@stephenh stephenh added the enhancement New feature or request label Aug 21, 2020
@stephenh
Copy link
Owner

stephenh commented Sep 7, 2020

@linarkou @cliedeman I've added supported for this in v1.32.0; I haven't updated the readme yet, but you'll have to use the protoc experimental flag mentioned in their docs. Please report any bugs if you try it and find anything wrong. Thanks!

@stephenh stephenh closed this as completed Sep 7, 2020
zfy0701 added a commit to sentioxyz/ts-proto that referenced this issue Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants