Closed gkoscky closed 5 months ago
Hi @gkoscky! That happens because AddRow
has a variadic argument with element type driver.Value
, which is much like having a []driver.Value
as single argument, and you are passing a []string
. To learn more, I recommend the following articles:
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.