Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spanner: SelectAll does not use the same field matching rules as Row.ToStruct #9415

Closed
CAFxX opened this issue Feb 13, 2024 · 0 comments · Fixed by #9417
Closed

spanner: SelectAll does not use the same field matching rules as Row.ToStruct #9415

CAFxX opened this issue Feb 13, 2024 · 0 comments · Fixed by #9417
Assignees
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.

Comments

@CAFxX
Copy link
Contributor

CAFxX commented Feb 13, 2024

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.

@CAFxX CAFxX added the triage me I really want to be triaged. label Feb 13, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants