-
Notifications
You must be signed in to change notification settings - Fork 926
Open
@honzap
Description
Version
1.30.0
What happened?
It's not possible to compile the query if id
column is in final WHERE condition. The query works towards PostgreSQL 17.5.
Maybe similar to #3924 and #3730
Relevant log output
sqlc generate failed. # package query.sql:15:7: column reference "id" is ambiguous
Database schema
CREATE TABLE employee ( id BIGSERIAL PRIMARY KEY, name text NOT NULL, parent_id bigint, deleted timestamp );
SQL queries
-- name: GetEmployeeTree :many WITH RECURSIVE parent_tree AS ( SELECT d1.id, d1.name, d1.parent_id FROM employee d1 WHERE d1.id = $1 AND d1.deleted IS NULL UNION ALL SELECT d2.id, d2.name, d2.parent_id FROM employee d2 INNER JOIN parent_tree pt ON d2.id = pt.parent_id WHERE d2.deleted IS NULL ) SELECT id, name FROM parent_tree WHERE id != $1 ORDER BY id DESC;
Configuration
{ "version": "2", "sql": [{ "schema": "schema.sql", "queries": "query.sql", "engine": "postgresql", "gen": { "go": { "out": "db" } } }] }
Playground URL
https://play.sqlc.dev/p/3f7877fb01113a2e517486e631e9f671243dfd5da891123c3775b163da4dce5e
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go