Skip to content

spanner/spannertest: unsupported inserting value kind into column of type UUID #20163

Description

@I82Much

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

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.triage meI really want to be triaged.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions