-
Notifications
You must be signed in to change notification settings - Fork 1.5k
spanner: SelectAll does not use the same field matching rules as Row.ToStruct #9415
Copy link
Copy link
Closed
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.triage meI really want to be triaged.I really want to be triaged.
Description
Assume a table like
CREATE TABLE test (
id INT64 NOT NULL,
name STRING(MAX),
) PRIMARY KEY (id);
Expected behavior
SelectAll, when passed a slice of
struct {
ID int64
Name string
}
should behave like Row.ToStruct, and perform case-insensitive comparison between the column name and the field name. In this case, this means mapping the id column to the ID field, and the name column to the Name field.
Actual behavior
Contrary to Row.ToStruct, SelectAll does not perform a case-insensitive compare, and thus returns the error Go struct {ID:0 Name:}(type reflect.Value) has no or duplicate fields for Cloud Spanner STRUCT field id.
Adding field tags like
struct {
ID int64 `spanner:"id"`
Name string `spanner:"name"`
}
makes the problem go away, but Row.ToStruct does not require them.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.triage meI really want to be triaged.I really want to be triaged.