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

Field presence support for proto3 #1497

Closed
wfansh opened this issue Apr 14, 2020 · 5 comments · Fixed by #1528
Closed

Field presence support for proto3 #1497

wfansh opened this issue Apr 14, 2020 · 5 comments · Fixed by #1528
Milestone

Comments

@wfansh
Copy link

wfansh commented Apr 14, 2020

Google will update the proto3 syntax to support "optional" for field presence:

  • Summary
    Add field presence to proto3 in a backward-compatible way by introducing the optional keyword with the same semantics as proto2.

  • .proto syntax changes
    Users can put optional on any proto3 field, with syntax and semantics identical to proto2:

syntax = "proto3";
message Foo {
  // Optional fields track presence.
  optional int32 a = 1;
  optional int64 b = 2;
  optional string c = 3;
  optional double d = 4;

Public announcement will come soon. Can we support this for proto3?

Removing line 299 - 301 would be OK.
https://github.com/square/wire/blob/master/wire-library/wire-schema/src/commonMain/kotlin/com/squareup/wire/schema/internal/parser/ProtoParser.kt#L299

@oldergod
Copy link
Member

oldergod commented Apr 14, 2020

Does this affect the encoding on the wire? what happens on a optional int32 of value 0? Same with decoding, is an optional int32 set to 0 or to null if there's no bytes for it?

@jwendel
Copy link

jwendel commented Apr 23, 2020

Looks like the doc has been posted describing this: https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md

@wfansh
Copy link
Author

wfansh commented Apr 24, 2020

Yes. That's the doc.

@wfansh
Copy link
Author

wfansh commented Apr 27, 2020

@oldergod oldergod modified the milestones: 3.3, 3.x Apr 30, 2020
@wfansh
Copy link
Author

wfansh commented May 1, 2020

Thanks guys!

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

Successfully merging a pull request may close this issue.

3 participants