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 generate errored with the message schema.sql:14:16: column "val" does not exist on a schema that is valid SQL
This happens when the schema has a view with a LATERAL join that selects a column from the outer query.
I've found a workaround where it works when I wrap it in a CASE WHEN true.
AI disclaimer: This is a real issue I encountered with a real schema, but I used AI to reduce this to a minimal reproducible schema.
Relevant log output
$ sqlc generate
# package queries
schema.sql:12:7: column "val" does not exist
Database schema
CREATETABLEfoo (id INTEGERPRIMARY KEY, val INTEGER)
;
CREATEVIEWfoo_lateralASSELECTt.val,
sub.resultFROM
foo t
CROSS JOIN LATERAL (
SELECTt.valAS result -- ERROR: column "val" does not exist-- CASE WHEN true THEN t.val END AS result -- This works!FROM
foo
LIMIT1
) sub
;
Activity