3 ms·
> using something with a solid schema that handles field names and types and gives you some way to find out when it's not even there [...] ex: protobuf In prot
by ricardobeat 7y ago
> using something with a solid schema that handles field names and types and gives you some way to find out when it's not even there [...] ex: protobuf
In proto3 all fields are optional, and have default values, so it becomes impossible to detect the absence of data unless you explicitly encode an empty/null state in your values.
- asark 7y agoEw, what was the reason for that?
- deleted 7y ago[deleted]
- jrockway 7y agoBecause in proto2 everyone used "optional" anyway.
- akavi 7y agoGo structs behave the same way. I wonder if one influenced the other.
- tantalor 7y ago> impossible to detect the absence of data There are other ways: - Check if the value different than the default, e.g., empty string - If your data is repeated, then check number of data elements != 0
- couchand 7y ago> Check if the value different than the default, e.g., empty string which is a worse version of the GP's > explicitly encode an empty/null state in your values
- aplusbi 7y agoThis is true for primitives but not [completely] true for messages. Message still have the "hasMessage" semantics. So if you truly need to differentiate between unset and default for primitives, you can box them in messages.