googleapis / googleapis/google-cloud-go

spannertest: column names are case sensitive unlike real cloud spanner

Open
#6,932 1 comment 0 reactions 2 assignees Claimed by @harshachinta View on GitHub
api: spanner priority: p3
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

The in memory spanner doesn't seem to be case insensitive when comparing column names...

```
// colIndexes returns the indexes for the named columns.
func (t *table) colIndexes(cols []spansql.ID) ([]int, error) {
var is []int
for _, col := range cols {
i, ok := t.colIndex[col]
if !ok {
return nil, status.Errorf(codes.InvalidArgument, "column %s not in table", col)
}
is = append(is, i)
}
return is, nil
}
```
I could try to make a patch if that's helpful. I think it's not as simple as just case normalizing the `colIndex` slice since case sensitivity matters for executing DDL.

**Code**

```go
package main

// Given schema
// CREATE TABLE Foo (
// id STRING(MAX) NOT NULL
// ) PRIMARY KEY(id);

type Foo {
Id string
}

func main() {
// ...
m, err := spanner.InsertStruct("Foo", &Foo{Id: "test"})
// ...
}
```

**Expected behavior**

InsertStruct should happily insert since there is an `id` column and the struct field is `Id`. This is what happens against Real Spanner (TM).

**Actual behavior**

In memory test implementation fails with `code = "InvalidArgument", desc = "column Id not in table"`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.