Skip to content

CTE in CTE relation does not exist #2004

Closed

Description

@PatrLind

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

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Dec 20, 2022
  2. kyleconroy commented on Oct 25, 2023

    @kyleconroy
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions