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 fields #235

Closed
Tracked by #237
pyramation opened this issue Oct 11, 2022 · 1 comment
Closed
Tracked by #237

optional fields #235

pyramation opened this issue Oct 11, 2022 · 1 comment

Comments

@pyramation
Copy link
Collaborator

match output from ts-proto as discussed in confio/cosmjs-types#40

This was referenced Oct 11, 2022
@pyramation
Copy link
Collaborator Author

The proto of this is:

message ExistenceProof {
    bytes key = 1;
    bytes value = 2;
    LeafOp leaf = 3;
    repeated InnerOp path = 4;    
}

but nested messages should be nullable by default if I recall correctly. This is described in detail here: https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md.

The nullable = false option of gogoproto exists because nullable is the default for messages. But it also comes with a warning:

Warning about nullable: According to the Protocol Buffer specification, you should be able to tell whether a field is set or unset. With the option nullable=false this feature is lost, since your non-nullable fields will always be set. It can be seen as a layer on top of Protocol Buffers, where before and after marshalling all non-nullable fields are set and they cannot be unset.

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

1 participant