diff --git a/bind.go b/bind.go index f683fcb4..369d73b2 100644 --- a/bind.go +++ b/bind.go @@ -249,11 +249,11 @@ func appendReflectSlice(args []interface{}, v reflect.Value, vlen int) []interfa args = append(args, val...) case []int: for i := range val { - args = append(args, &val[i]) + args = append(args, val[i]) } case []string: for i := range val { - args = append(args, &val[i]) + args = append(args, val[i]) } default: for si := 0; si < vlen; si++ { diff --git a/sqlx_test.go b/sqlx_test.go index 5ea754aa..a51528ea 100644 --- a/sqlx_test.go +++ b/sqlx_test.go @@ -1852,3 +1852,43 @@ func BenchmarkRebindBuffer(b *testing.B) { rebindBuff(DOLLAR, q2) } } + +func TestIn130Regression(t *testing.T) { + t.Run("[]interface{}{}", func(t *testing.T) { + q, args, err := In("SELECT * FROM people WHERE name IN (?)", []interface{}{[]string{"gopher"}}...) + if err != nil { + t.Fatal(err) + } + if q != "SELECT * FROM people WHERE name IN (?)" { + t.Errorf("got=%v", q) + } + t.Log(args) + for _, a := range args { + switch a.(type) { + case string: + t.Log("ok: string", a) + case *string: + t.Error("ng: string pointer", a, *a.(*string)) + } + } + }) + + t.Run("[]string{}", func(t *testing.T) { + q, args, err := In("SELECT * FROM people WHERE name IN (?)", []string{"gopher"}) + if err != nil { + t.Fatal(err) + } + if q != "SELECT * FROM people WHERE name IN (?)" { + t.Errorf("got=%v", q) + } + t.Log(args) + for _, a := range args { + switch a.(type) { + case string: + t.Log("ok: string", a) + case *string: + t.Error("ng: string pointer", a, *a.(*string)) + } + } + }) +}