Skip to content

Nested WITH doesn't work #2226

Closed
Closed
@hugosjoberg

Description

@hugosjoberg

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

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions