-
Notifications
You must be signed in to change notification settings - Fork 888
Support dynamic sized IN clauses #167
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
Comments
You're in luck! sqlc already supports this using
generate this method signature
|
Any way for this to work with mysql as well? Tried |
@kyleconroy I have the same issue, should this work for mysql or is it only available in postgres? |
Ditto, but sqlite. |
please use sqlc.slice() |
-- name: GetPeopleMany :many This won't work with enum type |
At the moment(Apr 2024) it works with enum types. You just need to specify the enum type (e.g. |
@mbesida This cause error:
|
I used it this way and it works like charm. -- name: GetPeopleMany :many
SELECT * FROM people
WHERE id IN (sqlc.slice('ids')); |
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.
See the large example on this page for a use-case: https://gqlgen.com/reference/dataloaders/
I am thinking something like:
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.
The text was updated successfully, but these errors were encountered: