Skip to content

Commit 9adbc06

Browse files
authored
Merge pull request jmoiron#340 from npiganeau/patch-2
[]byte should not be expanded by In
2 parents 5800ac0 + 364f96a commit 9adbc06

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

bind.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ func In(query string, args ...interface{}) (string, []interface{}, error) {
113113
v := reflect.ValueOf(arg)
114114
t := reflectx.Deref(v.Type())
115115

116-
if t.Kind() == reflect.Slice {
116+
// []byte is a driver.Value type so it should not be expanded
117+
if t.Kind() == reflect.Slice && t != reflect.TypeOf([]byte{}) {
117118
meta[i].length = v.Len()
118119
meta[i].v = v
119120

sqlx_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,9 @@ func TestIn(t *testing.T) {
14971497
{"SELECT * FROM foo WHERE x in (?)",
14981498
[]interface{}{[]int{1, 2, 3, 4, 5, 6, 7, 8}},
14991499
8},
1500+
{"SELECT * FROM foo WHERE x = ? AND y in (?)",
1501+
[]interface{}{[]byte("foo"), []int{0, 5, 3}},
1502+
4},
15001503
}
15011504
for _, test := range tests {
15021505
q, a, err := In(test.q, test.args...)

0 commit comments

Comments
 (0)