From 967d7bd54620cf5bbb6c5147b1ba34b0af9481d4 Mon Sep 17 00:00:00 2001 From: Codey Oxley Date: Wed, 20 Nov 2024 17:55:06 -0500 Subject: [PATCH 1/4] features/unmarshal_unique: fix codegen for keys/values --- Makefile | 1 + conformance/marshal.log | 0 features/unmarshal/unmarshal.go | 10 +- .../planetscale/vtprotobuf/vtproto/ext.proto | 1 + testproto/unique/unique.pb.go | 62 +- testproto/unique/unique.proto | 2 + testproto/unique/unique_test.go | 16 + testproto/unique/unique_vtproto.pb.go | 590 ++++++++++++++++++ vtproto/ext.pb.go | 2 +- 9 files changed, 664 insertions(+), 20 deletions(-) create mode 100644 conformance/marshal.log diff --git a/Makefile b/Makefile index 3cc625a2..36085559 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,7 @@ gen-testproto: get-grpc-testproto gen-wkt-testproto install testproto/proto3opt/opt.proto \ testproto/proto2/scalars.proto \ testproto/unsafe/unsafe.proto \ + testproto/unique/unique.proto \ || exit 1; $(PROTOBUF_ROOT)/src/protoc \ --proto_path=testproto \ diff --git a/conformance/marshal.log b/conformance/marshal.log new file mode 100644 index 00000000..e69de29b diff --git a/features/unmarshal/unmarshal.go b/features/unmarshal/unmarshal.go index 87f6ab69..c5540a51 100644 --- a/features/unmarshal/unmarshal.go +++ b/features/unmarshal/unmarshal.go @@ -157,9 +157,7 @@ func (p *unmarshal) declareMapField(varName string, nullable bool, field *protog } } -func (p *unmarshal) mapField(varName string, field *protogen.Field) { - unique := proto.GetExtension(field.Desc.Options(), vtproto.E_Options).(*vtproto.Opts).GetUnique() - +func (p *unmarshal) mapField(varName string, field *protogen.Field, unique bool) { switch field.Desc.Kind() { case protoreflect.DoubleKind: p.P(`var `, varName, `temp uint64`) @@ -509,6 +507,8 @@ func (p *unmarshal) fieldItem(field *protogen.Field, fieldname string, message * p.P(`m.`, fieldname, ` = &`, field.GoIdent, "{", field.GoName, `: v}`) p.P(`}`) } else if field.Desc.IsMap() { + unique := proto.GetExtension(field.Desc.Options(), vtproto.E_Options).(*vtproto.Opts).GetUnique() + goTyp, _ := p.FieldGoType(field) goTypK, _ := p.FieldGoType(field.Message.Fields[0]) goTypV, _ := p.FieldGoType(field.Message.Fields[1]) @@ -527,9 +527,9 @@ func (p *unmarshal) fieldItem(field *protogen.Field, fieldname string, message * p.P(`fieldNum := int32(wire >> 3)`) p.P(`if fieldNum == 1 {`) - p.mapField("mapkey", field.Message.Fields[0]) + p.mapField("mapkey", field.Message.Fields[0], unique) p.P(`} else if fieldNum == 2 {`) - p.mapField("mapvalue", field.Message.Fields[1]) + p.mapField("mapvalue", field.Message.Fields[1], unique) p.P(`} else {`) p.P(`iNdEx = entryPreIndex`) p.P(`skippy, err := `, p.Helper("Skip"), `(dAtA[iNdEx:])`) diff --git a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto index 21d78109..635f859e 100644 --- a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto +++ b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto @@ -20,4 +20,5 @@ extend google.protobuf.FieldOptions { // applying them to some of the fields in protobuf message Opts { optional bool unique = 1; + // optional bool unique_keys = 2; } diff --git a/testproto/unique/unique.pb.go b/testproto/unique/unique.pb.go index cc1fb68f..f9779f83 100644 --- a/testproto/unique/unique.pb.go +++ b/testproto/unique/unique.pb.go @@ -26,7 +26,9 @@ type UniqueFieldExtension struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` + Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar map[string]int64 `protobuf:"bytes,2,rep,name=bar,proto3" json:"bar,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Baz map[int64]string `protobuf:"bytes,3,rep,name=baz,proto3" json:"baz,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *UniqueFieldExtension) Reset() { @@ -68,6 +70,20 @@ func (x *UniqueFieldExtension) GetFoo() string { return "" } +func (x *UniqueFieldExtension) GetBar() map[string]int64 { + if x != nil { + return x.Bar + } + return nil +} + +func (x *UniqueFieldExtension) GetBaz() map[int64]string { + if x != nil { + return x.Baz + } + return nil +} + var File_unique_unique_proto protoreflect.FileDescriptor var file_unique_unique_proto_rawDesc = []byte{ @@ -75,12 +91,26 @@ var file_unique_unique_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x74, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x14, 0x55, 0x6e, - 0x69, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x07, 0xfa, 0xa3, 0xe8, 0x03, 0x02, 0x08, 0x01, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x42, 0x12, 0x5a, - 0x10, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x6e, 0x69, 0x71, 0x75, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x02, 0x0a, 0x14, 0x55, + 0x6e, 0x69, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x06, 0xb2, 0xa9, 0x1f, 0x02, 0x08, 0x01, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x38, 0x0a, + 0x03, 0x62, 0x61, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x55, 0x6e, 0x69, + 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x42, 0x61, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x06, 0xb2, 0xa9, 0x1f, 0x02, + 0x08, 0x01, 0x52, 0x03, 0x62, 0x61, 0x72, 0x12, 0x38, 0x0a, 0x03, 0x62, 0x61, 0x7a, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x42, 0x61, 0x7a, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x42, 0x06, 0xb2, 0xa9, 0x1f, 0x02, 0x08, 0x01, 0x52, 0x03, 0x62, 0x61, + 0x7a, 0x1a, 0x36, 0x0a, 0x08, 0x42, 0x61, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x36, 0x0a, 0x08, 0x42, 0x61, 0x7a, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x12, 0x5a, 0x10, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, + 0x6e, 0x69, 0x71, 0x75, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -95,16 +125,20 @@ func file_unique_unique_proto_rawDescGZIP() []byte { return file_unique_unique_proto_rawDescData } -var file_unique_unique_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_unique_unique_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_unique_unique_proto_goTypes = []interface{}{ (*UniqueFieldExtension)(nil), // 0: UniqueFieldExtension + nil, // 1: UniqueFieldExtension.BarEntry + nil, // 2: UniqueFieldExtension.BazEntry } var file_unique_unique_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: UniqueFieldExtension.bar:type_name -> UniqueFieldExtension.BarEntry + 2, // 1: UniqueFieldExtension.baz:type_name -> UniqueFieldExtension.BazEntry + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_unique_unique_proto_init() } @@ -132,7 +166,7 @@ func file_unique_unique_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_unique_unique_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/testproto/unique/unique.proto b/testproto/unique/unique.proto index 767023b2..e95e56e7 100644 --- a/testproto/unique/unique.proto +++ b/testproto/unique/unique.proto @@ -5,4 +5,6 @@ import "github.com/planetscale/vtprotobuf/vtproto/ext.proto"; message UniqueFieldExtension { string foo = 1 [(vtproto.options).unique = true]; + map bar = 2 [(vtproto.options).unique = true]; + map baz = 3 [(vtproto.options).unique = true]; } diff --git a/testproto/unique/unique_test.go b/testproto/unique/unique_test.go index bef40554..0fac9282 100644 --- a/testproto/unique/unique_test.go +++ b/testproto/unique/unique_test.go @@ -1,6 +1,8 @@ package unique import ( + "maps" + "slices" "testing" "unsafe" @@ -10,6 +12,8 @@ import ( func TestUnmarshalSameMemory(t *testing.T) { m := &UniqueFieldExtension{ Foo: "bar", + Bar: map[string]int64{"key": 100}, + Baz: map[int64]string{100: "value"}, } b, err := m.MarshalVTStrict() @@ -22,4 +26,16 @@ func TestUnmarshalSameMemory(t *testing.T) { require.NoError(t, m3.UnmarshalVT(b)) require.Equal(t, unsafe.StringData(m2.Foo), unsafe.StringData(m3.Foo)) + + keys2 := slices.Collect(maps.Keys(m2.Bar)) + keys3 := slices.Collect(maps.Keys(m3.Bar)) + require.Len(t, keys2, 1) + require.Len(t, keys3, 1) + require.Equal(t, unsafe.StringData(keys2[0]), unsafe.StringData(keys3[0])) + + values2 := slices.Collect(maps.Values(m2.Baz)) + values3 := slices.Collect(maps.Values(m3.Baz)) + require.Len(t, values2, 1) + require.Len(t, values2, 1) + require.Equal(t, unsafe.StringData(values2[0]), unsafe.StringData(values3[0])) } diff --git a/testproto/unique/unique_vtproto.pb.go b/testproto/unique/unique_vtproto.pb.go index d232bc83..4a8de2f1 100644 --- a/testproto/unique/unique_vtproto.pb.go +++ b/testproto/unique/unique_vtproto.pb.go @@ -27,6 +27,20 @@ func (m *UniqueFieldExtension) CloneVT() *UniqueFieldExtension { } r := new(UniqueFieldExtension) r.Foo = m.Foo + if rhs := m.Bar; rhs != nil { + tmpContainer := make(map[string]int64, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Bar = tmpContainer + } + if rhs := m.Baz; rhs != nil { + tmpContainer := make(map[int64]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Baz = tmpContainer + } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -47,6 +61,30 @@ func (this *UniqueFieldExtension) EqualVT(that *UniqueFieldExtension) bool { if this.Foo != that.Foo { return false } + if len(this.Bar) != len(that.Bar) { + return false + } + for i, vx := range this.Bar { + vy, ok := that.Bar[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + if len(this.Baz) != len(that.Baz) { + return false + } + for i, vx := range this.Baz { + vy, ok := that.Baz[i] + if !ok { + return false + } + if vx != vy { + return false + } + } return string(this.unknownFields) == string(that.unknownFields) } @@ -87,6 +125,40 @@ func (m *UniqueFieldExtension) MarshalToSizedBufferVT(dAtA []byte) (int, error) i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if len(m.Baz) > 0 { + for k := range m.Baz { + v := m.Baz[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i = protohelpers.EncodeVarint(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Bar) > 0 { + for k := range m.Bar { + v := m.Bar[k] + baseI := i + i = protohelpers.EncodeVarint(dAtA, i, uint64(v)) + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } if len(m.Foo) > 0 { i -= len(m.Foo) copy(dAtA[i:], m.Foo) @@ -127,6 +199,40 @@ func (m *UniqueFieldExtension) MarshalToSizedBufferVTStrict(dAtA []byte) (int, e i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if len(m.Baz) > 0 { + for k := range m.Baz { + v := m.Baz[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i = protohelpers.EncodeVarint(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Bar) > 0 { + for k := range m.Bar { + v := m.Bar[k] + baseI := i + i = protohelpers.EncodeVarint(dAtA, i, uint64(v)) + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } if len(m.Foo) > 0 { i -= len(m.Foo) copy(dAtA[i:], m.Foo) @@ -147,6 +253,22 @@ func (m *UniqueFieldExtension) SizeVT() (n int) { if l > 0 { n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } + if len(m.Bar) > 0 { + for k, v := range m.Bar { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + protohelpers.SizeOfVarint(uint64(v)) + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if len(m.Baz) > 0 { + for k, v := range m.Baz { + _ = k + _ = v + mapEntrySize := 1 + protohelpers.SizeOfVarint(uint64(k)) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } n += len(m.unknownFields) return n } @@ -216,6 +338,240 @@ func (m *UniqueFieldExtension) UnmarshalVT(dAtA []byte) error { } m.Foo = stringValue iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Bar == nil { + m.Bar = make(map[string]int64) + } + var mapkey string + var mapvalue int64 + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapkey == 0 { + mapkey = "" + } else { + mapkey = unique.Make[string](unsafe.String(&dAtA[iNdEx], intStringLenmapkey)).Value() + } + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvalue |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Bar[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Baz", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Baz == nil { + m.Baz = make(map[int64]string) + } + var mapkey int64 + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapvalue == 0 { + mapvalue = "" + } else { + mapvalue = unique.Make[string](unsafe.String(&dAtA[iNdEx], intStringLenmapvalue)).Value() + } + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Baz[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) @@ -303,6 +659,240 @@ func (m *UniqueFieldExtension) UnmarshalVTUnsafe(dAtA []byte) error { } m.Foo = stringValue iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Bar == nil { + m.Bar = make(map[string]int64) + } + var mapkey string + var mapvalue int64 + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapkey == 0 { + mapkey = "" + } else { + mapkey = unsafe.String(&dAtA[iNdEx], intStringLenmapkey) + } + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvalue |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Bar[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Baz", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Baz == nil { + m.Baz = make(map[int64]string) + } + var mapkey int64 + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + if intStringLenmapvalue == 0 { + mapvalue = "" + } else { + mapvalue = unsafe.String(&dAtA[iNdEx], intStringLenmapvalue) + } + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Baz[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) diff --git a/vtproto/ext.pb.go b/vtproto/ext.pb.go index e296959e..39eaa8b7 100644 --- a/vtproto/ext.pb.go +++ b/vtproto/ext.pb.go @@ -28,7 +28,7 @@ type Opts struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Unique *bool `protobuf:"varint,1,opt,name=unique" json:"unique,omitempty"` + Unique *bool `protobuf:"varint,1,opt,name=unique" json:"unique,omitempty"` // optional bool unique_keys = 2; } func (x *Opts) Reset() { From 50928762cbddb6b0aff62979fdc8b95cd347df81 Mon Sep 17 00:00:00 2001 From: Codey Oxley Date: Wed, 20 Nov 2024 17:59:26 -0500 Subject: [PATCH 2/4] remove errant comment --- conformance/marshal.log | 89 +++++++++++++++++++ .../planetscale/vtprotobuf/vtproto/ext.proto | 1 - 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/conformance/marshal.log b/conformance/marshal.log index e69de29b..2c4d8fd3 100644 --- a/conformance/marshal.log +++ b/conformance/marshal.log @@ -0,0 +1,89 @@ +MARSHAL +message: +map_string_string: { + key: "a" + value: "value" +} +map_string_string: { + key: "b" + value: "value" +} +map_string_string: { + key: "c" + value: "value" +} + + +expected: +00000000 aa 04 0a 0a 01 61 12 05 76 61 6c 75 65 aa 04 0a |.....a..value...| +00000010 0a 01 62 12 05 76 61 6c 75 65 aa 04 0a 0a 01 63 |..b..value.....c| +00000020 12 05 76 61 6c 75 65 |..value| + + +got: +00000000 aa 04 0a 0a 01 63 12 05 76 61 6c 75 65 aa 04 0a |.....c..value...| +00000010 0a 01 62 12 05 76 61 6c 75 65 aa 04 0a 0a 01 61 |..b..value.....a| +00000020 12 05 76 61 6c 75 65 |..value| + + +golang: +&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:39, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32(nil), MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool(nil), MapStringString:map[string]string{"a":"value", "b":"value", "c":"value"}, MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} + +============== + +MARSHAL +message: +map_int32_int32: { + key: 1 + value: 0 +} +map_int32_int32: { + key: 2 + value: 0 +} +map_int32_int32: { + key: 3 + value: 0 +} + + +expected: +00000000 c2 03 04 08 01 10 00 c2 03 04 08 02 10 00 c2 03 |................| +00000010 04 08 03 10 00 |.....| + + +got: +00000000 c2 03 04 08 01 10 00 c2 03 04 08 03 10 00 c2 03 |................| +00000010 04 08 02 10 00 |.....| + + +golang: +&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:21, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32{1:0, 2:0, 3:0}, MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool(nil), MapStringString:map[string]string(nil), MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} + +============== + +MARSHAL +message: +map_bool_bool: { + key: false + value: false +} +map_bool_bool: { + key: true + value: false +} + + +expected: +00000000 a2 04 04 08 00 10 00 a2 04 04 08 01 10 00 |..............| + + +got: +00000000 a2 04 04 08 01 10 00 a2 04 04 08 00 10 00 |..............| + + +golang: +&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:14, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32(nil), MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool{false:false, true:false}, MapStringString:map[string]string(nil), MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} + +============== + diff --git a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto index 635f859e..21d78109 100644 --- a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto +++ b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto @@ -20,5 +20,4 @@ extend google.protobuf.FieldOptions { // applying them to some of the fields in protobuf message Opts { optional bool unique = 1; - // optional bool unique_keys = 2; } From 67b70f61159cd547c4404ab7dd37d5c8dbbc3a8a Mon Sep 17 00:00:00 2001 From: Codey Oxley Date: Wed, 20 Nov 2024 18:05:08 -0500 Subject: [PATCH 3/4] make tests actually verify what we're trying to --- testproto/unique/unique_test.go | 6 +++--- vtproto/ext.pb.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testproto/unique/unique_test.go b/testproto/unique/unique_test.go index 0fac9282..6ae7bda7 100644 --- a/testproto/unique/unique_test.go +++ b/testproto/unique/unique_test.go @@ -25,17 +25,17 @@ func TestUnmarshalSameMemory(t *testing.T) { m3 := &UniqueFieldExtension{} require.NoError(t, m3.UnmarshalVT(b)) - require.Equal(t, unsafe.StringData(m2.Foo), unsafe.StringData(m3.Foo)) + require.Same(t, unsafe.StringData(m2.Foo), unsafe.StringData(m3.Foo), "string field") keys2 := slices.Collect(maps.Keys(m2.Bar)) keys3 := slices.Collect(maps.Keys(m3.Bar)) require.Len(t, keys2, 1) require.Len(t, keys3, 1) - require.Equal(t, unsafe.StringData(keys2[0]), unsafe.StringData(keys3[0])) + require.Same(t, unsafe.StringData(keys2[0]), unsafe.StringData(keys3[0]), "string key") values2 := slices.Collect(maps.Values(m2.Baz)) values3 := slices.Collect(maps.Values(m3.Baz)) require.Len(t, values2, 1) require.Len(t, values2, 1) - require.Equal(t, unsafe.StringData(values2[0]), unsafe.StringData(values3[0])) + require.Same(t, unsafe.StringData(values2[0]), unsafe.StringData(values3[0]), "string value") } diff --git a/vtproto/ext.pb.go b/vtproto/ext.pb.go index 39eaa8b7..e296959e 100644 --- a/vtproto/ext.pb.go +++ b/vtproto/ext.pb.go @@ -28,7 +28,7 @@ type Opts struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Unique *bool `protobuf:"varint,1,opt,name=unique" json:"unique,omitempty"` // optional bool unique_keys = 2; + Unique *bool `protobuf:"varint,1,opt,name=unique" json:"unique,omitempty"` } func (x *Opts) Reset() { From bbb5fcea3ec46f0961b10039acbee8b91b0319f9 Mon Sep 17 00:00:00 2001 From: Codey Oxley Date: Thu, 21 Nov 2024 07:22:30 -0500 Subject: [PATCH 4/4] remove marshal.log and ignore --- .gitignore | 1 + conformance/marshal.log | 89 ----------------------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 conformance/marshal.log diff --git a/.gitignore b/.gitignore index ef80c500..08fa25d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin _vendor +conformance/marshal.log diff --git a/conformance/marshal.log b/conformance/marshal.log deleted file mode 100644 index 2c4d8fd3..00000000 --- a/conformance/marshal.log +++ /dev/null @@ -1,89 +0,0 @@ -MARSHAL -message: -map_string_string: { - key: "a" - value: "value" -} -map_string_string: { - key: "b" - value: "value" -} -map_string_string: { - key: "c" - value: "value" -} - - -expected: -00000000 aa 04 0a 0a 01 61 12 05 76 61 6c 75 65 aa 04 0a |.....a..value...| -00000010 0a 01 62 12 05 76 61 6c 75 65 aa 04 0a 0a 01 63 |..b..value.....c| -00000020 12 05 76 61 6c 75 65 |..value| - - -got: -00000000 aa 04 0a 0a 01 63 12 05 76 61 6c 75 65 aa 04 0a |.....c..value...| -00000010 0a 01 62 12 05 76 61 6c 75 65 aa 04 0a 0a 01 61 |..b..value.....a| -00000020 12 05 76 61 6c 75 65 |..value| - - -golang: -&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:39, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32(nil), MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool(nil), MapStringString:map[string]string{"a":"value", "b":"value", "c":"value"}, MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} - -============== - -MARSHAL -message: -map_int32_int32: { - key: 1 - value: 0 -} -map_int32_int32: { - key: 2 - value: 0 -} -map_int32_int32: { - key: 3 - value: 0 -} - - -expected: -00000000 c2 03 04 08 01 10 00 c2 03 04 08 02 10 00 c2 03 |................| -00000010 04 08 03 10 00 |.....| - - -got: -00000000 c2 03 04 08 01 10 00 c2 03 04 08 03 10 00 c2 03 |................| -00000010 04 08 02 10 00 |.....| - - -golang: -&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:21, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32{1:0, 2:0, 3:0}, MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool(nil), MapStringString:map[string]string(nil), MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} - -============== - -MARSHAL -message: -map_bool_bool: { - key: false - value: false -} -map_bool_bool: { - key: true - value: false -} - - -expected: -00000000 a2 04 04 08 00 10 00 a2 04 04 08 01 10 00 |..............| - - -got: -00000000 a2 04 04 08 01 10 00 a2 04 04 08 00 10 00 |..............| - - -golang: -&conformance.TestAllTypesProto3{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000116008)}, sizeCache:14, unknownFields:[]uint8(nil), OptionalInt32:0, OptionalInt64:0, OptionalUint32:0x0, OptionalUint64:0x0, OptionalSint32:0, OptionalSint64:0, OptionalFixed32:0x0, OptionalFixed64:0x0, OptionalSfixed32:0, OptionalSfixed64:0, OptionalFloat:0, OptionalDouble:0, OptionalBool:false, OptionalString:"", OptionalBytes:[]uint8(nil), OptionalNestedMessage:(*conformance.TestAllTypesProto3_NestedMessage)(nil), OptionalForeignMessage:(*conformance.ForeignMessage)(nil), OptionalNestedEnum:0, OptionalForeignEnum:0, OptionalAliasedEnum:0, OptionalStringPiece:"", OptionalCord:"", RecursiveMessage:(*conformance.TestAllTypesProto3)(nil), RepeatedInt32:[]int32(nil), RepeatedInt64:[]int64(nil), RepeatedUint32:[]uint32(nil), RepeatedUint64:[]uint64(nil), RepeatedSint32:[]int32(nil), RepeatedSint64:[]int64(nil), RepeatedFixed32:[]uint32(nil), RepeatedFixed64:[]uint64(nil), RepeatedSfixed32:[]int32(nil), RepeatedSfixed64:[]int64(nil), RepeatedFloat:[]float32(nil), RepeatedDouble:[]float64(nil), RepeatedBool:[]bool(nil), RepeatedString:[]string(nil), RepeatedBytes:[][]uint8(nil), RepeatedNestedMessage:[]*conformance.TestAllTypesProto3_NestedMessage(nil), RepeatedForeignMessage:[]*conformance.ForeignMessage(nil), RepeatedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), RepeatedForeignEnum:[]conformance.ForeignEnum(nil), RepeatedStringPiece:[]string(nil), RepeatedCord:[]string(nil), PackedInt32:[]int32(nil), PackedInt64:[]int64(nil), PackedUint32:[]uint32(nil), PackedUint64:[]uint64(nil), PackedSint32:[]int32(nil), PackedSint64:[]int64(nil), PackedFixed32:[]uint32(nil), PackedFixed64:[]uint64(nil), PackedSfixed32:[]int32(nil), PackedSfixed64:[]int64(nil), PackedFloat:[]float32(nil), PackedDouble:[]float64(nil), PackedBool:[]bool(nil), PackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), UnpackedInt32:[]int32(nil), UnpackedInt64:[]int64(nil), UnpackedUint32:[]uint32(nil), UnpackedUint64:[]uint64(nil), UnpackedSint32:[]int32(nil), UnpackedSint64:[]int64(nil), UnpackedFixed32:[]uint32(nil), UnpackedFixed64:[]uint64(nil), UnpackedSfixed32:[]int32(nil), UnpackedSfixed64:[]int64(nil), UnpackedFloat:[]float32(nil), UnpackedDouble:[]float64(nil), UnpackedBool:[]bool(nil), UnpackedNestedEnum:[]conformance.TestAllTypesProto3_NestedEnum(nil), MapInt32Int32:map[int32]int32(nil), MapInt64Int64:map[int64]int64(nil), MapUint32Uint32:map[uint32]uint32(nil), MapUint64Uint64:map[uint64]uint64(nil), MapSint32Sint32:map[int32]int32(nil), MapSint64Sint64:map[int64]int64(nil), MapFixed32Fixed32:map[uint32]uint32(nil), MapFixed64Fixed64:map[uint64]uint64(nil), MapSfixed32Sfixed32:map[int32]int32(nil), MapSfixed64Sfixed64:map[int64]int64(nil), MapInt32Float:map[int32]float32(nil), MapInt32Double:map[int32]float64(nil), MapBoolBool:map[bool]bool{false:false, true:false}, MapStringString:map[string]string(nil), MapStringBytes:map[string][]uint8(nil), MapStringNestedMessage:map[string]*conformance.TestAllTypesProto3_NestedMessage(nil), MapStringForeignMessage:map[string]*conformance.ForeignMessage(nil), MapStringNestedEnum:map[string]conformance.TestAllTypesProto3_NestedEnum(nil), MapStringForeignEnum:map[string]conformance.ForeignEnum(nil), OneofField:conformance.isTestAllTypesProto3_OneofField(nil), OptionalBoolWrapper:(*wrapperspb.BoolValue)(nil), OptionalInt32Wrapper:(*wrapperspb.Int32Value)(nil), OptionalInt64Wrapper:(*wrapperspb.Int64Value)(nil), OptionalUint32Wrapper:(*wrapperspb.UInt32Value)(nil), OptionalUint64Wrapper:(*wrapperspb.UInt64Value)(nil), OptionalFloatWrapper:(*wrapperspb.FloatValue)(nil), OptionalDoubleWrapper:(*wrapperspb.DoubleValue)(nil), OptionalStringWrapper:(*wrapperspb.StringValue)(nil), OptionalBytesWrapper:(*wrapperspb.BytesValue)(nil), RepeatedBoolWrapper:[]*wrapperspb.BoolValue(nil), RepeatedInt32Wrapper:[]*wrapperspb.Int32Value(nil), RepeatedInt64Wrapper:[]*wrapperspb.Int64Value(nil), RepeatedUint32Wrapper:[]*wrapperspb.UInt32Value(nil), RepeatedUint64Wrapper:[]*wrapperspb.UInt64Value(nil), RepeatedFloatWrapper:[]*wrapperspb.FloatValue(nil), RepeatedDoubleWrapper:[]*wrapperspb.DoubleValue(nil), RepeatedStringWrapper:[]*wrapperspb.StringValue(nil), RepeatedBytesWrapper:[]*wrapperspb.BytesValue(nil), OptionalDuration:(*durationpb.Duration)(nil), OptionalTimestamp:(*timestamppb.Timestamp)(nil), OptionalFieldMask:(*fieldmaskpb.FieldMask)(nil), OptionalStruct:(*structpb.Struct)(nil), OptionalAny:(*anypb.Any)(nil), OptionalValue:(*structpb.Value)(nil), OptionalNullValue:0, RepeatedDuration:[]*durationpb.Duration(nil), RepeatedTimestamp:[]*timestamppb.Timestamp(nil), RepeatedFieldmask:[]*fieldmaskpb.FieldMask(nil), RepeatedStruct:[]*structpb.Struct(nil), RepeatedAny:[]*anypb.Any(nil), RepeatedValue:[]*structpb.Value(nil), RepeatedListValue:[]*structpb.ListValue(nil), Fieldname1:0, FieldName2:0, XFieldName3:0, Field_Name4_:0, Field0Name5:0, Field_0Name6:0, FieldName7:0, FieldName8:0, Field_Name9:0, Field_Name10:0, FIELD_NAME11:0, FIELDName12:0, XFieldName13:0, X_FieldName14:0, Field_Name15:0, Field__Name16:0, FieldName17__:0, FieldName18__:0} - -============== -