Closed
Description
A MySQL query like:
SELECT * FROM things WHERE foo = sqlc.arg(foo) OR old_foo = sqlc.arg(foo)
gets compiled into:
const query = `SELECT * FROM things WHERE foo = ? OR old_foo = ?`
func (q *Queries) GetThingByFoo(ctx context.Context, foo string) (Thing, error) {
row := q.db.QueryRowContext(ctx, query, foo)
...
}
which causes MySQL to complain because only one argument is supplied when it was expecting two.
It seems like we should at least error out during code generation in this case, but even better would be to do:
row := q.db.QueryRowContext(ctx, query, foo, foo)