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
SQLC fails to generate a query where I try to use a column from a subquery in a WHERE clause to compare against a query argument, which is a valid SQL syntax for SQLite. The same query compiles successfully I use a literal value instead of an argument.
P.S. I've tried reproducing it in the playground and it seems that it actually compiles successfully on v1.25.0 but not on v1.26 or newer.
Relevant log output
# package db
queries.sql:7:7: table alias"a" does not exist
Database schema
CREATETABLEposts (
id BIGSERIALPRIMARY KEY,
tags TEXT-- JSON array of hashtags like ["#foo", "#bar"]
);
SQL queries
-- name: GetPostIDsByTag :manySELECT DISTINCTa.idFROM (
SELECTp.id, ltrim(json_each.value->>'$.name', '#') AS tag
FROM posts p, json_each(p.tags)
) a
WHEREa.tag='foo';
SELECT
things,
bool_and(bool_things)
FROM (
SELECT things, bool_things FROM some_things
UNION
SELECT things, bool_things FROM other_things
) AS x
WHERE x.things = $1
GROUP BY x.things;
The above query results in the following error: table alias "x" does not exist
Version
1.27.0
What happened?
SQLC fails to generate a query where I try to use a column from a subquery in a WHERE clause to compare against a query argument, which is a valid SQL syntax for SQLite. The same query compiles successfully I use a literal value instead of an argument.
P.S. I've tried reproducing it in the playground and it seems that it actually compiles successfully on v1.25.0 but not on v1.26 or newer.
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/33831f5ac4e36ae1654164ae929c04ed981a51b135d20aca35e492573f00c8b0
What operating system are you using?
macOS
What database engines are you using?
SQLite
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: