Re: [protobuf] Default Values vs Missing Values

2016-05-26 Thread Teddy Zhang
I've created an issue for this: https://github.com/google/protobuf/issues/1606 -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [protobuf] Default Values vs Missing Values

2016-05-18 Thread Teddy Zhang
On Wednesday, May 18, 2016 at 11:32:03 AM UTC-7, Feng Xiao wrote: > > > > On Tue, May 17, 2016 at 7:53 PM, Teddy Zhang > wrote: > >> I'm really not happy to see that proto3 removed the ability in generate >> code for check whether a field exits or not. >> >> For a message

Re: [protobuf] Default Values vs Missing Values

2016-05-18 Thread Teddy Zhang
On Wednesday, May 18, 2016 at 11:32:03 AM UTC-7, Feng Xiao wrote: > > > > On Tue, May 17, 2016 at 7:53 PM, Teddy Zhang > wrote: > >> I'm really not happy to see that proto3 removed the ability in generate >> code for check whether a field exits or not. >> >> For a message

Re: [protobuf] Default Values vs Missing Values

2016-05-18 Thread 'Feng Xiao' via Protocol Buffers
On Tue, May 17, 2016 at 7:53 PM, Teddy Zhang wrote: > I'm really not happy to see that proto3 removed the ability in generate > code for check whether a field exits or not. > > For a message like this: > message Test1 { > required int32 a = 1; > } > If field a is present,

Re: [protobuf] Default Values vs Missing Values

2016-05-17 Thread Teddy Zhang
I'm really not happy to see that proto3 removed the ability in generate code for check whether a field exits or not. For a message like this: message Test1 { required int32 a = 1; } If field a is present, the encoded message will have field with id 1 and its value. If the field is not set,

Re: [protobuf] Default Values vs Missing Values

2016-03-29 Thread Ilia Mirkin
You can't distinguish an empty repeated from one that's not there at all. If you need that, you'll need a manual presence field. On Tue, Mar 29, 2016 at 2:02 AM, Yoav H wrote: > How do they handle collections (repeated, non packed) in this case? > The absence of the tag

Re: [protobuf] Default Values vs Missing Values

2016-03-29 Thread Yoav H
How do they handle collections (repeated, non packed) in this case? The absence of the tag is not conclusive. Actually, even packed collection (and strings, and binary data) suffer from that, as you are "expected" to not include a packed collection with zero bytes. On Saturday, March 26, 2016

Re: [protobuf] Default Values vs Missing Values

2016-03-26 Thread Ilia Mirkin
Encoding is identical... just the API is different. In proto2, you have (in C++) FooMessage->has_field() which will tell you whether a field was present in the encoded version (or has been set prior if you're building a new message). The Java API has something rather similar... hasField() I think?

Re: [protobuf] Default Values vs Missing Values

2016-03-26 Thread Yoav H
Thanks all, Do you know where I can find the proto2 encoding guide? The proto site has only the proto3 encoding described. On Saturday, March 26, 2016 at 12:21:39 PM UTC-7, Tim Kientzle wrote: > > > > On Mar 26, 2016, at 11:43 AM, Yoav H > wrote: > > > > Hi, > > > >

Re: [protobuf] Default Values vs Missing Values

2016-03-26 Thread Tim Kientzle
> On Mar 26, 2016, at 11:43 AM, Yoav H wrote: > > Hi, > > I wanted ask regarding the decision to populate fields with default values, > even if they do not appear in the encoded message. > If I want to send a "patch" message, where I want to update just the provided

Re: [protobuf] Default Values vs Missing Values

2016-03-26 Thread Ilia Mirkin
Use proto2, which has the has_* checks per field. (Using get_* you still get the default value, of course.) It's extremely unfortunate that this functionality was removed in proto3, I see that making proto3 unattractive for all but the simplest uses of protos. I know in almost every protobuf

[protobuf] Default Values vs Missing Values

2016-03-26 Thread Yoav H
Hi, I wanted ask regarding the decision to populate fields with default values, even if they do not appear in the encoded message. If I want to send a "patch" message, where I want to update just the provided fields, how can I do that with protobuf (without adding IsXXXSet for every field)?