Open juniorgarcia opened 3 weeks ago
After some testing I saw (by completely guessing) that changing the last line to LIMIT :limit OFFSET :offset
works properly, generating the query:
-- name: GetTodosForUser :many
SELECT id, title, description, done
FROM
todos
WHERE
user_id = ? AND
done = COALESCE(?2, done) AND
title LIKE COALESCE(CONCAT("%", ?3, "%"), title) AND
description LIKE COALESCE(CONCAT("%", ?4, "%"), description)
LIMIT ? OFFSET ?;
If that's the right way of writing this query, is it in the docs? Couldn't find anything about it.
Edit: add more information
Version
1.27.0
What happened?
I tried to create a quite simple
SELECT
query and was not sure why theLIMIT
andOFFSET
params were not working properly. After inspecting the generated code I saw that, for some reason, the order of theLIMIT
andOFFSET
placeholders were switched and this was causing the odd behavior.Below, the generated query :
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/031a5a5c121bc1679aea839a3d47c3787d723bb2af4b0b51553d868e2721536e
What operating system are you using?
macOS
What database engines are you using?
SQLite
What type of code are you generating?
Go