sqlc
sqlc copied to clipboard
Code for pgx/v4 doesn't compile with same named input and output param
Version
1.12.0
What happened?
I have a query that takes id
as its only input, and also returns id
as its only output.
That causes the function arg and a variable to be called id
, thus failing compilation.
Fascinating is that this only breaks with pgx/v4, not with database/sql. The latter seems to reuse the variable and make it work.
Relevant log output
gendb/queries.sql.go:16:6: id redeclared in this block
gendb/queries.sql.go:14:68: previous declaration
Database schema
No response
SQL queries
INSERT INTO authors (name) SELECT name FROM authors a WHERE a.id = $1 RETURNING id;
Configuration
No response
Playground URL
https://play.sqlc.dev/p/d7186cbc2c17613b4ab6fc927330fb20d7848c5c7eb75e975e8d3e55a53a279a
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Similar bug to https://github.com/kyleconroy/sqlc/issues/1453
Seems to fixed by #1298
Seems to fixed by #1298
Just tried - but the issue still occurs in sqlc v1.16.0.
@sgielen Oh, #1298 seems to have been fixed only for the stdlib template. 🙇 I try to fix for the pgx template. #2058