diff --git a/README.md b/README.md index 5bfd231a1..e103dfd13 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ In addition to the [godoc API documentation](http://godoc.org/github.com/jmoiron there is also some [user documentation](http://jmoiron.github.io/sqlx/) that explains how to use `database/sql` along with sqlx. +`sqlx.In` always expands with `?` placeholders. Even on PostgreSQL, write +`IN (?)` (not `IN ($1)`), then `db.Rebind` the query before running it. + ## Recent Changes 1.3.0: diff --git a/bind.go b/bind.go index e6980392b..4f6642640 100644 --- a/bind.go +++ b/bind.go @@ -137,8 +137,13 @@ func asSliceForIn(i interface{}) (v reflect.Value, ok bool) { } // In expands slice values in args, returning the modified query string -// and a new arg list that can be executed by a database. The `query` should -// use the `?` bindVar. The return value uses the `?` bindVar. +// and a new arg list that can be executed by a database. +// +// The query must use the `?` bindVar (not `$1`, `@p1`, etc.), even when +// targeting PostgreSQL or other drivers that normally use a different +// placeholder style. In always returns a query that still uses `?`; call +// db.Rebind on the result before Query/Exec so the placeholders match the +// driver. func In(query string, args ...interface{}) (string, []interface{}, error) { // argMeta stores reflect.Value and length for slices and // the value itself for non-slice arguments