You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
COALESCE in INSERT results in missing arguments #2748
I think the bug is sadly worse than your description, and I'll probably update the title. It appears that sqlc fails to generate input parameters for values passed to COALESCE in INSERT statements, even without sqlc.narg(). And I also see this behavior with PostgreSQL.
Interestingly this does indeed seem particular to COALESCE. I went back and tried a couple of other functions like substrings (both for postgresql and the mysql variant) but they seem ok.
Activity
andrewmbenton commentedon Sep 21, 2023
I think the bug is sadly worse than your description, and I'll probably update the title. It appears that sqlc fails to generate input parameters for values passed to
COALESCEinINSERTstatements, even withoutsqlc.narg(). And I also see this behavior with PostgreSQL.This playground link updates the one you provided to demonstrate that things work fine in the context of
UPDATE: https://play.sqlc.dev/p/0d614a07b58fbacdea078b51d5e6d338414dc6558059249294c29f74212f9104And here's a playground link demonstrating the bug using PostgreSQL as engine and without
sqlc.narg(): https://play.sqlc.dev/p/28b5372fd509a34792e30e7eb62bbbe74d400ab7e7cb1652d58bc9f7ee1ec5e7[-]COALESCE and narg results in missing arguments[/-][+]COALESCE in INSERT results in missing arguments[/+]andrei-dascalu commentedon Sep 21, 2023
Interestingly this does indeed seem particular to COALESCE. I went back and tried a couple of other functions like substrings (both for postgresql and the mysql variant) but they seem ok.
orisano commentedon Sep 21, 2023
The problem occurs because COALESCE is treated as CoalesceExpr instead of FuncCall on ast.
kyleconroy commentedon Oct 12, 2023
Fix has been merged, will be included in v1.23.0