Open dennissetiawan opened 12 months ago
Hey!
Encountered the same issue when passing two arguments to SelectBuilder.Where
.
For example:
testQuery := sq.Select("test").
From("test").
Where("? = ?", 1, 2)
query, args, err := testQuery.ToSql()
fmt.Printf("query: %s\n", query)
fmt.Printf("args: %v\n", args)
query: SELECT test FROM test WHERE ? = ?
args: [1 2]
This is the error I get.
*errors.errorString have no arg for param ? at position 1
This doesn't happen with SelectBuilder.Having
for example.
Turns out I was not passing args
as a slice in the follow-up implementation. The issue was not related to this library.
My bad!
I noticed something weird why can't we use ? in column name?
sql, args, err := sb.Select("test").Where("y = ?", 2).ToSql()
OK butsql, args, err := sb.Select("test").Where("? = ?","y", 2).ToSql()
errorthis also happens in sq.Expr