Version
1.27.0
What happened?
sqlc fails to parse UPDATE statements that include both RETURNING and ORDER BY / LIMIT clauses.
Relevant log output
line 53:13 no viable alternative at input ';'
line 60:0 extraneous input 'order' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
# package sqlc
query.sql:1:1: extraneous input 'order' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
db.go:5: running "sqlc": exit status 1
Database schema
CREATE TABLE queue (
qid integer primary key,
domain varchar not null,
lock_ts varchar not null default '',
create_ts varchar not null default current_timestamp
);
CREATE UNIQUE INDEX queue_domain on queue(domain);
SQL queries
-- name: LockQueueNext :one
update queue
set lock_ts = current_timestamp
where lock_ts = ''
returning *
order by qid limit 1;
Configuration
version: 2
sql:
- engine: "sqlite"
schema: "db/migrations"
queries: "query.sql"
gen:
go:
package: "sqlc"
out: "sqlc"
Playground URL
https://play.sqlc.dev/p/aef8481b79a2285af6ed4f04d801f0f59201be3ffce00df2bef824421bed477f
What operating system are you using?
Linux
What database engines are you using?
SQLite
What type of code are you generating?
Go
Version
1.27.0
What happened?
sqlc fails to parse UPDATE statements that include both RETURNING and ORDER BY / LIMIT clauses.
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/aef8481b79a2285af6ed4f04d801f0f59201be3ffce00df2bef824421bed477f
What operating system are you using?
Linux
What database engines are you using?
SQLite
What type of code are you generating?
Go