-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameters with Array type have incorrect names #243
Comments
Agreed that this is a bug. In the meantime, you can use named parameters to get the correct parameter name: -- name: ListPilotsByIDs :many
SELECT * FROM pilots
WHERE id = ANY(sqlc.arg(ids)::int[]); Or using the -- name: ListPilotsByIDs :many
SELECT * FROM pilots
WHERE id = ANY(@ids::int[]); |
Below doesn't work. any solution to this? (ANSWERED) -- name: ListTransfers :many
SELECT * FROM transfers
WHERE
from_account_id = ANY(sqlc.arg(from_account_ids)::int[]) OR
to_account_id = ANY(sqlc.arg(to_account_ids)::int[])
ORDER BY id
LIMIT $1
OFFSET $2; error
Update: LIMIT sqlc.arg(limit) Update: LIMIT sqlc.arg('limit') |
@kyleconroy How can I accomplish the above example in MySQL?
|
Looks like sqlc needs to support passing slices to MySQL queries #695 first |
This can be accomplished in MySQL and SQLite using sqlc.slice. As for the parameter name, sqlc.arg Anand named parameters solve this issue nicely. |
What happened?
Hello, I'm trying to generate Go Code from SQL Query using ANY method. When I run
sqlc generate
, variable with array method gets unexpected name.Actual result: Variable with []int type gets
dollar_1
nameExpected result: Variable gets
IDs
nameNote: variable might get
Column + Number
name (e.g. Column4) when sql query contains several ANY methods in it.Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/455e276514a8ecf33f4d86175da22a6965058d86d08a9e127c59e3a3a9acbad4
The text was updated successfully, but these errors were encountered: