From d1af029104e9b594a99209484914b822addb08fa Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 25 May 2018 14:12:43 -0700 Subject: Fixed JS parsing of unspecified map keys We need to use a default of 0 when parsing unspecified map keys, instead of failing an assertion. This change was written by Michael Aaron (michaelaaron@google.com) but I am cherry-picking it directly instead of waiting for the next sync of Google-internal changes. --- js/testbinary.proto | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'js/testbinary.proto') diff --git a/js/testbinary.proto b/js/testbinary.proto index 116f17fb..ed5bdfc6 100644 --- a/js/testbinary.proto +++ b/js/testbinary.proto @@ -201,6 +201,38 @@ message TestMapFields { map map_string_testmapfields = 12; } +// These proto are 'mock map' entries to test the above map deserializing with +// undefined keys. Make sure TestMapFieldsOptionalKeys is written to be +// deserialized by TestMapFields +message MapEntryOptionalKeysStringKey { + optional string key = 1; + optional string value = 2; +} + +message MapEntryOptionalKeysInt32Key { + optional int32 key = 1; + optional string value = 2; +} + +message MapEntryOptionalKeysInt64Key { + optional int64 key = 1; + optional string value = 2; +} + +message MapEntryOptionalKeysBoolKey { + optional bool key = 1; + optional string value = 2; +} + +message TestMapFieldsOptionalKeys { + optional MapEntryOptionalKeysStringKey map_string_string = 1; + optional MapEntryOptionalKeysInt32Key map_int32_string= 8; + optional MapEntryOptionalKeysInt64Key map_int64_string = 9; + optional MapEntryOptionalKeysBoolKey map_bool_string = 10; +} + +// End mock-map entries + enum MapValueEnum { MAP_VALUE_FOO = 0; MAP_VALUE_BAR = 1; -- cgit v1.2.3