Expected Behavior
Creating a table with a UUID column in spannertest and inserting a UUID string should succeed when applying mutations:
dbName := "projects/test-proj/instances/test-inst/databases/test-db"
op, err := adminClient.UpdateDatabaseDdl(ctx, &databasepb.UpdateDatabaseDdlRequest{
Database: dbName,
Statements: []string{
`CREATE TABLE Tasks (
TaskId UUID NOT NULL,
Data STRING(MAX),
) PRIMARY KEY (TaskId)`,
},
})
taskID := uuid.NewString()
mut := spanner.Insert("Tasks", []string{"TaskId", "Data"}, []any{taskID, "some-data"})
_, err = client.Apply(ctx, []*spanner.Mutation{mut})
Actual Behavior
client.Apply fails with an unsupported value error:
spanner: code = "Unknown", desc = "rpc error: code = Unknown desc = unsupported inserting value kind *structpb.Value_StringValue into column of
type UUID"
Cause
valForType in spanner/spannertest/db.go lacks a case handling spansql.UUID for structpb.Value_StringValue , and spannerTypeFromType in
spanner/spannertest/inmem.go lacks spansql.UUID in spannerpb.TypeCode RPC type mapping.
Additional Context
I have a fix and tests ready in a Pull Request.
Internally this is b/533798889
Expected Behavior
Creating a table with a
UUIDcolumn inspannertestand inserting a UUID string should succeed when applying mutations:Actual Behavior
client.Apply fails with an unsupported value error:
Cause
valForType in spanner/spannertest/db.go lacks a case handling spansql.UUID for structpb.Value_StringValue , and spannerTypeFromType in
spanner/spannertest/inmem.go lacks spansql.UUID in spannerpb.TypeCode RPC type mapping.
Additional Context
I have a fix and tests ready in a Pull Request.
Internally this is b/533798889