How to make OFFSET and LIMIT attributes in postgresql query are optional when using SQLC to generate Golang code?

302 views Asked by At

Here is my query statement to be generated. But I want the offset and limit attributes are optional.

-- name: ListTransfersTo :many

SELECT *
FROM transfers
WHERE to_account_id = $1
ORDER BY created_at
OFFSET $2
LIMIT $3;

I try to do following https://github.com/sqlc-dev/sqlc/issues/1155 to solve this problem by using OFFSET sqlc.arg('offset', nullable => true) and LIMIT sqlc.arg('limit', nullable => true) but it returns an error: expected 1 parameter to sqlc.arg; got 2 after using sqlc generate. Thanks for your supports.

0

There are 0 answers