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
You should add support for a query with a dynamically sized list of values for an IN clause in a WHERE segment. This would be useful for when you are using a dataloader to get data from the database. This is most useful for graphql servers.
-- name: GetPeopleMany :manySELECT*FROM people
WHERE id IN ($);
would generate a go function that takes in a slice of values for the input. This is distinguished from just wanting a single value by only having the $ instead of $1.
Activity
kyleconroy commentedon Dec 13, 2019
You're in luck! sqlc already supports this using
ANY. The following SQL:generate this method signature
markschmid commentedon Nov 21, 2020
Any way for this to work with mysql as well? Tried
ANY(?::int[])but it reports a syntax error.SebastienMelki commentedon Jul 25, 2022
@kyleconroy I have the same issue, should this work for mysql or is it only available in postgres?
josharian commentedon Jul 28, 2023
Ditto, but sqlite.
orisano commentedon Jul 29, 2023
please use sqlc.slice()
https://play.sqlc.dev/p/ed1b1d235f3a32c811a27dec68d826b4c0c36dedf0e614f0339fa02e11cc4ba4
iceteahh commentedon Dec 27, 2023
-- name: GetPeopleMany :many
SELECT * FROM people
WHERE id = ANY($1::int[]);
This won't work with enum type
mbesida commentedon Apr 4, 2024
At the moment(Apr 2024) it works with enum types. You just need to specify the enum type (e.g.
ANY($1::MyEnum[]))psnehanshu commentedon May 8, 2025
@mbesida This cause error:
BijaySharma commentedon May 29, 2025
I used it this way and it works like charm.