Skip to content

Subquery Alias causing panic #153

Closed

Description

@arddor

I tried to do a more efficient distinct query (the second query) and noticed that the generation panics on the alias of a subquery. The first query shows a simpler example on how to cause this issue.

panic: walk: unexpected node type *pg_query.Alias
-- schema.sql
CREATE TABLE authors (
  id BIGSERIAL PRIMARY KEY,
  name TEXT NOT NULL,
  bio TEXT
);
-- name: SubAuthors :many
SELECT sub.name FROM (SELECT * FROM authors) sub

-- name: ListDistinctAuthors :many
WITH RECURSIVE temp (t) AS (
    (SELECT name from authors LIMIT 1)
    UNION ALL
    (SELECT name FROM temp, LATERAL (SELECT name FROM authors where name > t LIMIT 1) sub)
)
SELECT t from temp;

Activity

  1. added a commit that references this issue on Dec 12, 2019
    61cd7f1
  2. added a commit that references this issue on Dec 12, 2019
    1078c18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions