-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.
Description
Client
Spanner
Environment
go version go1.23.2 darwin/arm64
Code and Dependencies
package main
func main() {
// spannerClient created per best practices
rowIter := spannerClient.Single().Query(
context.Background(),
spanner.Statement{SQL: `
SELECT
Id,
OtherId,
FROM Items
ORDER BY OtherId DESC
`},
)
defer rowIter.Stop()
var dest []struct {
Id string
OtherId Inner[string]
}
if err := spanner.SelectAll(rowIter, &dest); err != nil {
t.Fatal(err)
}
for _, d := range dest {
fmt.Println(d)
}
}
type Inner[T any] struct {
val T
}
func (n *Inner[T]) DecodeSpanner(input any) error {
switch val := input.(type) {
case T:
n.val = val
return nil
case *T:
if val == nil {
return nil
}
n.val = *val
return nil
}
panic("n/a")
}
go.mod
module modname
go 1.23
require (
cloud.google.com/go/spanner v1.70.0
google.golang.org/api v0.201.0
google.golang.org/grpc v1.67.1
…
)
Expected behavior
Given the following data in the table Items
:
Id OtherId
715e8f8d None
5865d2cd foobar
with the schema
CREATE TABLE IF NOT EXISTS Items (
Id STRING(36) DEFAULT (GENERATE_UUID()),
OtherId STRING(MAX),
) PRIMARY KEY (Id);
and running the above code, I would expect
{5865d2cd {foobar}}
{715e8f8d {}}
Actual behavior
I see a row mismatch, where the row 715e8f8d
somehow inherits the value foobar
from 5865d2cd
.
{5865d2cd {foobar}}
{715e8f8d {foobar}}
(guids truncated for pith)
Additional context
Is not an issue when iterating and decoding using ToStruct()
.
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.