diff --git a/driver_with_mockserver_test.go b/driver_with_mockserver_test.go index 8f29b3ed..42721809 100644 --- a/driver_with_mockserver_test.go +++ b/driver_with_mockserver_test.go @@ -478,7 +478,7 @@ func TestQueryWithAllTypes(t *testing.T) { true, "test", []byte("testbytes"), - int64(5), + uint(5), 3.14, numeric("6.626"), civil.Date{Year: 2021, Month: 7, Day: 21}, diff --git a/stmt.go b/stmt.go index a12ddddb..3e600fc7 100644 --- a/stmt.go +++ b/stmt.go @@ -78,11 +78,37 @@ func prepareSpannerStmt(q string, args []driver.NamedValue) (spanner.Statement, if name == "" { name = names[i] } - ss.Params[name] = v.Value + ss.Params[name] = convertParam(v.Value) } return ss, nil } +func convertParam(v driver.Value) driver.Value { + switch v.(type) { + default: + return v + case uint: + return int64(v.(uint)) + case []uint: + vu := v.([]uint) + res := make([]int64, len(vu)) + for i, val := range vu { + res[i] = int64(val) + } + return res + case *uint: + vi := int64(*v.(*uint)) + return &vi + case *[]uint: + vu := v.(*[]uint) + res := make([]int64, len(*vu)) + for i, val := range *vu { + res[i] = int64(val) + } + return &res + } +} + type result struct { rowsAffected int64 }