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
Column/table references inside aggregate functions are not validated against the schema #4300
sqlc does not validate table or column references used inside PostgreSQL aggregate functions (e.g. ARRAY_AGG, JSON_AGG, etc.) against the known schema. A query referencing a completely non-existent relation inside an aggregate compiles without any error, and Go code is generated for it.
For example, whatever is not a table, view, alias, or CTE anywhere in the schema, yet the following query passes validation and produces generated code:
-- name: BugDemo :execSELECT id, ARRAY_AGG(whatever.*) FROM worker;
PostgreSQL itself rejects this query at execution time with:
ERROR: missing FROM-clause entry for table "whatever"
Expected behavior
sqlc should report a compile-time error indicating that whatever is not a valid relation, the same way it would if whatever were referenced outside of an aggregate function (e.g. SELECT whatever.* FROM worker does produce an error).
Actual behavior
sqlc silently accepts the query and generates valid-looking Go code:
Activity
nikolayk812 commentedon Feb 16, 2026
This is similar I believe: #4291