Closed
Description
Version
1.17.2
What happened?
When a WITH is nested it doesn't work. The query works when running the query directly against postgres but fails when running in SQLC.
Relevant log output
/query.sql:9:1: relation "summary" does not exist
Database schema
-- Example queries for sqlc
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
-- name: GetAuthor :one
WITH person AS(
WITH summary AS(
WITH mb AS(
select
*
from authors
)
SELECT
bio
FROM mb
)
SELECT
count(*)
FROM summary
)
select * from person;
Configuration
No response
Playground URL
https://play.sqlc.dev/p/e3b1e1370d95e38ad655fb46b019f20172272b6298e112ee9bf770878979bd00
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
test: Add case for #2226
test: Add more test cases for new analyzer (#2879)
kyleconroy commentedon Oct 24, 2023
This is fixed in v1.23.0 by enabling the database-backed query analyzer. We added a test case for this issue so it won’t break in the future.
You can play around with the working example on the playground