Open AvicennaJr opened 8 months ago
Same thing here: when i set my where condition to a constant it works, but when the condition is dynamic, i get error:
WHERE models.make_id = 47;
this works
WHERE models.make_id = @in_make_id;
this on does not
WHERE models.make_id = (sqlc.arg(in_make_id));
this one neither
I expect https://github.com/sqlc-dev/sqlc/pull/3220 to fix this
I have the same, table aliases are not recognaized
Hi everyone This error persist since 2022. Can someone ping the pull request https://github.com/sqlc-dev/sqlc/pull/3220 How one can possibly work without CTE or joins? Is SQLC only for primitive cases?
Please, pay attention to issues: https://github.com/sqlc-dev/sqlc/issues/2400 https://github.com/sqlc-dev/sqlc/issues/3169 https://github.com/sqlc-dev/sqlc/issues/1385
Same thing here: when i set my where condition to a constant it works, but when the condition is dynamic, i get error:
WHERE models.make_id = 47;
this worksWHERE models.make_id = @in_make_id;
this on does notWHERE models.make_id = (sqlc.arg(in_make_id));
this one neither
same issue here with sqlite
this seems to work for me:
WHERE models.make_id = cast(sqlc.arg(in_make_id) as integer);
@kyleconroy a vanilla use case in probably the most popular non-embedded database, postgres (and seemingly also the most popular embedded database, sqlite), is broken, with a bad error message to boot. Can we get a TTR for this bug, guidance on acceptable PRs, or anything at all?
+1 having this same issue, super annoying makes where clauses based on CTE's basically unusable
same issue here with sqlite this seems to work for me:
WHERE models.make_id = cast(sqlc.arg(in_make_id) as integer);
Yeah, casting seems to remedy this, for whatever reason. WHERE models.make_id = @in_make_id::INTEGER;
works for me with postgres.
Version
1.25.0
What happened?
Sqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_table.field = 'something'.
I've provided a simple example to replicate the issue
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/388ae1f5e3a9ab6c0185bdfce9ead7acbbb6ece3d6a52d828cd40184b109caf3
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go