Skip to content

CTE in CTE relation does not exist #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PatrLind opened this issue Dec 20, 2022 · 1 comment
Closed

CTE in CTE relation does not exist #2004

PatrLind opened this issue Dec 20, 2022 · 1 comment

Comments

@PatrLind
Copy link

Version

Other

What happened?

Version: v1.16.0

It seems like sqlc doesn't support CTE in CTE.

Possible duplicates or related issues: #1916, #1912

Relevant log output

The error message I get is:
`test.sql:1:1: relation "a" does not exist`

Database schema

No response

SQL queries

This is my test query:

WITH total AS (
    WITH a AS (
    	SELECT 1 AS col1, 2 AS col2
    ),
    b AS (
    	SELECT 1 AS col1, 3 AS col3
    )
    SELECT *
    FROM a
    FULL JOIN b USING (col1)
)
SELECT * FROM total;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/ff29ae3267b95b9b42036ad8fdb76cf62d98d0b2c4f44a92bc028f16ebd88e06

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@PatrLind PatrLind added bug Something isn't working triage New issues that hasn't been reviewed labels Dec 20, 2022
@andrewmbenton andrewmbenton added 📚 postgresql 🔧 golang 💻 linux and removed triage New issues that hasn't been reviewed labels Jun 7, 2023
@kyleconroy
Copy link
Collaborator

This is partially fixed in v1.23.0 by enabling the database-backed query analyzer. You can play around with the working example on the playground

Star expansion for this query fails with the database-backed analyzer, which I'm tracking in #2915

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants