You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query 'SELECT * FROM my_table WHERE columnA = ? AND columnB = ? AND columnC IN (?, ?)',
arguments do not match: expected 1, but got 4 arguments
The error makes sense, because I am passing queryArgs ([]string) to WithArgs, while the actual Queryx(query, args...) method gets an unpacked []interface{} as its arguments. But doing a similar AddRow(queryArgs...) results in:
cannot use queryArgs (variable of type []string) as []driver.Value value in argument to mock.ExpectQuery
Which leads me to my question: How can I pass an array to WithArgs that would match the unpacked arguments passed to Queryx?
I know I could hard code it, but in the non-simplified version of this code, the number of arguments is variable for each test case.
The text was updated successfully, but these errors were encountered:
I have a
sqlx.Query
being called on a named query with multiple parameters. You can see a working example, but here's the abridged version:And then a test case like so
Which results in this error message:
The error makes sense, because I am passing
queryArgs ([]string)
toWithArgs
, while the actualQueryx(query, args...)
method gets an unpacked[]interface{}
as its arguments. But doing a similarAddRow(queryArgs...)
results in:Which leads me to my question: How can I pass an array to
WithArgs
that would match the unpacked arguments passed toQueryx
?I know I could hard code it, but in the non-simplified version of this code, the number of arguments is variable for each test case.
The text was updated successfully, but these errors were encountered: