Skip to content

Commit

Permalink
feat(spanner): fix schema naming (googleapis#10194)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshachinta authored May 16, 2024
1 parent 0a86d50 commit 215e0c8
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 90 deletions.
32 changes: 16 additions & 16 deletions spanner/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2271,19 +2271,19 @@ func TestIntegration_BasicTypes_ProtoColumns(t *testing.T) {
defer cancel()
stmts := []string{
`CREATE PROTO BUNDLE (
spanner.examples.music.SingerInfo,
spanner.examples.music.Genre,
examples.spanner.music.SingerInfo,
examples.spanner.music.Genre,
)`,
`CREATE TABLE Types (
RowID INT64 NOT NULL,
Int64a INT64,
Bytes BYTES(MAX),
Int64Array ARRAY<INT64>,
BytesArray ARRAY<BYTES(MAX)>,
ProtoMessage spanner.examples.music.SingerInfo,
ProtoEnum spanner.examples.music.Genre,
ProtoMessageArray ARRAY<spanner.examples.music.SingerInfo>,
ProtoEnumArray ARRAY<spanner.examples.music.Genre>,
ProtoMessage examples.spanner.music.SingerInfo,
ProtoEnum examples.spanner.music.Genre,
ProtoMessageArray ARRAY<examples.spanner.music.SingerInfo>,
ProtoEnumArray ARRAY<examples.spanner.music.Genre>,
) PRIMARY KEY (RowID)`,
}

Expand Down Expand Up @@ -2512,19 +2512,19 @@ func TestIntegration_BasicTypes_ProtoColumns_Errors(t *testing.T) {
defer cancel()
stmts := []string{
`CREATE PROTO BUNDLE (
spanner.examples.music.SingerInfo,
spanner.examples.music.Genre,
examples.spanner.music.SingerInfo,
examples.spanner.music.Genre,
)`,
`CREATE TABLE Types (
RowID INT64 NOT NULL,
Int64a INT64,
Bytes BYTES(MAX),
Int64Array ARRAY<INT64>,
BytesArray ARRAY<BYTES(MAX)>,
ProtoMessage spanner.examples.music.SingerInfo,
ProtoEnum spanner.examples.music.Genre,
ProtoMessageArray ARRAY<spanner.examples.music.SingerInfo>,
ProtoEnumArray ARRAY<spanner.examples.music.Genre>,
ProtoMessage examples.spanner.music.SingerInfo,
ProtoEnum examples.spanner.music.Genre,
ProtoMessageArray ARRAY<examples.spanner.music.SingerInfo>,
ProtoEnumArray ARRAY<examples.spanner.music.Genre>,
) PRIMARY KEY (RowID)`,
}
protoDescriptor := readProtoDescriptorFile()
Expand Down Expand Up @@ -2607,15 +2607,15 @@ func TestIntegration_ProtoColumns_DML_ParameterizedQueries_Pk_Indexes(t *testing
defer cancel()
stmts := []string{
`CREATE PROTO BUNDLE (
spanner.examples.music.SingerInfo,
spanner.examples.music.Genre,
examples.spanner.music.SingerInfo,
examples.spanner.music.Genre,
)`,
`CREATE TABLE Singers (
SingerId INT64 NOT NULL,
FirstName STRING(1024),
LastName STRING(1024),
SingerInfo spanner.examples.music.SingerInfo,
SingerGenre spanner.examples.music.Genre,
SingerInfo examples.spanner.music.SingerInfo,
SingerGenre examples.spanner.music.Genre,
SingerNationality STRING(1024) AS (SingerInfo.nationality) STORED,
) PRIMARY KEY (SingerNationality, SingerGenre)`,
`CREATE INDEX SingerByNationalityAndGenre ON Singers(SingerNationality, SingerGenre) STORING (SingerId, FirstName, LastName)`,
Expand Down
5 changes: 5 additions & 0 deletions spanner/testdata/protos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### To generate singer.pb.go and descriptors.pb file from singer.proto using `protoc`
```shell
cd spanner/testdata
protoc --proto_path=protos/ --include_imports --descriptor_set_out=protos/descriptors.pb --go_out=protos/ protos/singer.proto
```
Binary file modified spanner/testdata/protos/descriptors.pb
Binary file not shown.
138 changes: 70 additions & 68 deletions spanner/testdata/protos/singer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spanner/testdata/protos/singer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.

syntax = "proto2";

package spanner.examples.music;
option go_package = "./protos";
package examples.spanner.music;
option go_package = "./";

message SingerInfo {
optional int64 singer_id = 1;
Expand Down
8 changes: 4 additions & 4 deletions spanner/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ func TestEncodeValue(t *testing.T) {
Nationality: proto.String("Country2"),
Genre: &singer2ProtoEnum,
}
protoMessagefqn := "spanner.examples.music.SingerInfo"
protoEnumfqn := "spanner.examples.music.Genre"
protoMessagefqn := "examples.spanner.music.SingerInfo"
protoEnumfqn := "examples.spanner.music.Genre"

var (
tString = stringType()
Expand Down Expand Up @@ -1536,8 +1536,8 @@ func TestDecodeValue(t *testing.T) {
Nationality: proto.String("Country2"),
Genre: &singer2ProtoEnum,
}
protoMessagefqn := "spanner.examples.music.SingerInfo"
protoEnumfqn := "spanner.examples.music.Genre"
protoMessagefqn := "examples.spanner.music.SingerInfo"
protoEnumfqn := "examples.spanner.music.Genre"

for _, test := range []struct {
desc string
Expand Down

0 comments on commit 215e0c8

Please sign in to comment.