diff --git a/spanner/integration_test.go b/spanner/integration_test.go index 979782d91e46..8ea92ff7537c 100644 --- a/spanner/integration_test.go +++ b/spanner/integration_test.go @@ -2463,7 +2463,16 @@ func TestIntegration_BasicTypes_ProtoColumns(t *testing.T) { if want == nil { want = test.val } - gotp := reflect.New(reflect.TypeOf(want)) + + var gotp reflect.Value + switch want.(type) { + case proto.Message: + // We are passing a pointer of proto message in `want` due to `go vet` issue. + // Through the switch case, we are dereferencing the value so that we get proto message instead of its pointer. + gotp = reflect.New(reflect.TypeOf(want).Elem()) + default: + gotp = reflect.New(reflect.TypeOf(want)) + } v := gotp.Interface() switch nullValue := v.(type) { diff --git a/spanner/testdata/protos/descriptors.pb b/spanner/testdata/protos/descriptors.pb index d4c018f3a3c2..10193075ede5 100644 Binary files a/spanner/testdata/protos/descriptors.pb and b/spanner/testdata/protos/descriptors.pb differ diff --git a/spanner/testdata/protos/singer.pb.go b/spanner/testdata/protos/singer.pb.go index 32b07cdb238c..080aa6b036fc 100644 --- a/spanner/testdata/protos/singer.pb.go +++ b/spanner/testdata/protos/singer.pb.go @@ -1,23 +1,22 @@ -/* -Copyright 2024 Google LLC - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +// +//Copyright 2024 Google LLC +// +//Licensed under the Apache License, Version 2.0 (the "License"); +//you may not use this file except in compliance with the License. +//You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, software +//distributed under the License is distributed on an "AS IS" BASIS, +//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//See the License for the specific language governing permissions and +//limitations under the License. // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.21.12 +// protoc v4.25.1 // source: singer.proto package protos @@ -84,16 +83,6 @@ func (x Genre) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Do not use. -func (x *Genre) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = Genre(num) - return nil -} - // Deprecated: Use Genre.Descriptor instead. func (Genre) EnumDescriptor() ([]byte, []int) { return file_singer_proto_rawDescGZIP(), []int{0} @@ -104,10 +93,10 @@ type SingerInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SingerId *int64 `protobuf:"varint,1,opt,name=singer_id,json=singerId" json:"singer_id,omitempty"` - BirthDate *string `protobuf:"bytes,2,opt,name=birth_date,json=birthDate" json:"birth_date,omitempty"` - Nationality *string `protobuf:"bytes,3,opt,name=nationality" json:"nationality,omitempty"` - Genre *Genre `protobuf:"varint,4,opt,name=genre,enum=examples.spanner.music.Genre" json:"genre,omitempty"` + SingerId *int64 `protobuf:"varint,1,opt,name=singer_id,json=singerId,proto3,oneof" json:"singer_id,omitempty"` + BirthDate *string `protobuf:"bytes,2,opt,name=birth_date,json=birthDate,proto3,oneof" json:"birth_date,omitempty"` + Nationality *string `protobuf:"bytes,3,opt,name=nationality,proto3,oneof" json:"nationality,omitempty"` + Genre *Genre `protobuf:"varint,4,opt,name=genre,proto3,enum=examples.spanner.music.Genre,oneof" json:"genre,omitempty"` } func (x *SingerInfo) Reset() { @@ -175,21 +164,26 @@ var File_singer_proto protoreflect.FileDescriptor var file_singer_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x73, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x72, - 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x22, 0x9f, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x6e, 0x67, 0x65, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x69, 0x6e, 0x67, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x69, 0x72, 0x74, 0x68, 0x5f, 0x64, 0x61, 0x74, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x12, 0x33, 0x0a, 0x05, 0x67, 0x65, 0x6e, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x70, - 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x2e, 0x47, 0x65, 0x6e, 0x72, - 0x65, 0x52, 0x05, 0x67, 0x65, 0x6e, 0x72, 0x65, 0x2a, 0x2e, 0x0a, 0x05, 0x47, 0x65, 0x6e, 0x72, - 0x65, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x4f, 0x50, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4a, 0x41, - 0x5a, 0x5a, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x4f, 0x4c, 0x4b, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x52, 0x4f, 0x43, 0x4b, 0x10, 0x03, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x73, + 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x22, 0xea, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x6e, 0x67, 0x65, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x73, 0x69, 0x6e, 0x67, + 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x22, 0x0a, 0x0a, 0x62, 0x69, 0x72, 0x74, 0x68, + 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x09, 0x62, + 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, 0x6e, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x02, 0x52, 0x0b, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x88, + 0x01, 0x01, 0x12, 0x38, 0x0a, 0x05, 0x67, 0x65, 0x6e, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x1d, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x70, 0x61, + 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63, 0x2e, 0x47, 0x65, 0x6e, 0x72, 0x65, + 0x48, 0x03, 0x52, 0x05, 0x67, 0x65, 0x6e, 0x72, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, + 0x5f, 0x73, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x62, + 0x69, 0x72, 0x74, 0x68, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x67, 0x65, + 0x6e, 0x72, 0x65, 0x2a, 0x2e, 0x0a, 0x05, 0x47, 0x65, 0x6e, 0x72, 0x65, 0x12, 0x07, 0x0a, 0x03, + 0x50, 0x4f, 0x50, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4a, 0x41, 0x5a, 0x5a, 0x10, 0x01, 0x12, + 0x08, 0x0a, 0x04, 0x46, 0x4f, 0x4c, 0x4b, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x4f, 0x43, + 0x4b, 0x10, 0x03, 0x42, 0x09, 0x5a, 0x07, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -238,6 +232,7 @@ func file_singer_proto_init() { } } } + file_singer_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/spanner/testdata/protos/singer.proto b/spanner/testdata/protos/singer.proto index b87bf3529370..bae04443d5c4 100644 --- a/spanner/testdata/protos/singer.proto +++ b/spanner/testdata/protos/singer.proto @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -syntax = "proto2"; +syntax = "proto3"; package examples.spanner.music; -option go_package = "./"; +option go_package = "protos/"; message SingerInfo { optional int64 singer_id = 1;