sqlc
sqlc copied to clipboard
sqlite: parentheses in filter change generated functions
Version
1.15.0
What happened?
I wanted to add following query:
-- name: NextTask :one
SELECT id
FROM dt_tasks
WHERE
(execute_at IS NULL
OR execute_at <= ?)
AND task_status = 'scheduled'
LIMIT 1;
but the function it generates doesn't contain the parameter:
func (q *Queries) NextTask(ctx context.Context) (int64, error)
and using it returns an error: "not enough args to execute query: want 1 got 0".
When I remove the parentheses in the filter the generated function takes the additional parameter. I could make it work when I change the query to:
-- name: NextTask :one
SELECT id
FROM tasks
WHERE
execute_at IS NULL
AND task_status = 'scheduled'
OR execute_at <= ?
AND task_status = 'scheduled'
LIMIT 1;
The generated function has following signature:
func (q *Queries) NextTask(ctx context.Context, executeAt sql.NullString) (int64, error)
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
No response
What type of code are you generating?
Go