On Tuesday, March 19, 2019 at 6:50:37 PM UTC-4, Adam Cozzette wrote: > > Not exactly, by unknown enum value I mean an enum value that doesn't > appear in the enum definition. For example let's say your enum has only > values 0, 1, and 2 but you parse a 3. This could happen if the message was > serialized by another binary using a newer version of the schema. Proto2 > will store unknown enum values in the unknown field set whereas proto3 will > just store them normally in the field. >
I think in the above scenario, that would likely break whether v2 or v3, but I could be wrong. I would have to re-read the language guide. You can parse an ordinal value where the Enumeration was expected? i.e. UNKNOWN = 0; Would accept 0 or UNKNOWN? Are we talking descriptor / protobuf specification level? Or binary level? I do not read any biases where unexpected ordinal values are concerned, but I would expect that it fail any sort of verification. That being said, specification versioning is a concern regardless of whether v2 or v3, I think, and not just with Protocol Buffers. It's a concern for this type of framework, regardless. On Thu, Mar 14, 2019 at 7:29 PM Jason Huang <[email protected] > <javascript:>> wrote: > >> thanks for your reply , as for the `unknown enum values` , do you mean >> the case of a unseted enum field ? >> >> On Friday, 15 March 2019 02:12:31 UTC+8, Adam Cozzette wrote: >>> >>> Going from proto3 to proto2 should be fine. There are some slight >>> differences but I can't think of any major problems. The only thing that >>> comes to mind is that proto2 handles unknown enum values a little bit >>> differently from proto3. I doubt that would be a problem but if you want to >>> be extra cautious you could double-check that you're not storing any >>> unknown enum values. >>> >>> However, there is no need to downgrade to version 2.6.1 and if anything >>> that would only introduce bugs and make the code slower. The proto2 >>> semantics are still fully supported in all versions going forward, so all >>> you have to do is put syntax = "proto2"; at the top of your .proto >>> files. You can stick with 3.6.1 or even upgrade to any newer version. >>> >>> On Thu, Mar 14, 2019 at 10:21 AM Jason Huang <[email protected]> >>> wrote: >>> >>>> i chose proto3 for cache (serialize) for my application , and it have >>>> run for several month . but now i wanna change my mind for proto2 , >>>> because >>>> the hasField is really needed . >>>> >>>> the problem is , there're still lots of data in the cache which are >>>> serialized with proto3 , if i can't deserialize with them with proto2 . it >>>> will be unacceptable . >>>> >>>> my question is , is it safe to switch from proto3 to proto2 ? i made >>>> some test i could work in some case . but i'm afraid this is not full >>>> coverage test . >>>> >>>> my current proto3 version is 3.6.1 , and the proto2 version i want to >>>> use is 2.6.1 >>>> >>>> -- >>>> 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 [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at https://groups.google.com/group/protobuf. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/protobuf. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
