Skip to content

Commit

Permalink
Added comment and test
Browse files Browse the repository at this point in the history
  • Loading branch information
npiganeau committed Jul 18, 2017
1 parent f9cd482 commit 364f96a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func In(query string, args ...interface{}) (string, []interface{}, error) {
v := reflect.ValueOf(arg)
t := reflectx.Deref(v.Type())

// []byte is a driver.Value type so it should not be expanded
if t.Kind() == reflect.Slice && t != reflect.TypeOf([]byte{}) {
meta[i].length = v.Len()
meta[i].v = v
Expand Down
3 changes: 3 additions & 0 deletions sqlx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,9 @@ func TestIn(t *testing.T) {
{"SELECT * FROM foo WHERE x in (?)",
[]interface{}{[]int{1, 2, 3, 4, 5, 6, 7, 8}},
8},
{"SELECT * FROM foo WHERE x = ? AND y in (?)",
[]interface{}{[]byte("foo"), []int{0, 5, 3}},
4},
}
for _, test := range tests {
q, a, err := In(test.q, test.args...)
Expand Down

0 comments on commit 364f96a

Please sign in to comment.