Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ In addition to the [API documentation](https://pkg.go.dev/github.com/secondwindo
there is also upstream's [user guide](https://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.

## About this fork

This is a maintained fork of [jmoiron/sqlx](https://github.com/jmoiron/sqlx).
Expand Down
9 changes: 7 additions & 2 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading