Skip to content

WITH clause unable to find relation #2136

Closed
@markdessain

Description

@markdessain

Version

1.17.2

What happened?

The following is valid when running it in the sqlite command line:

sqlite> WITH abc AS (
   ...>   SELECT 1 AS n
   ...> )
   ...> SELECT * FROM abc;
1

but when selecting the sqlite engine and running it through sqlc generate it throws the following error:

sqlc generate failed.
package db
query.sql:1:1: relation "abc" does not exist

If I switch the engine from sqlite to be postgresql it works as expected. Which suggests the issue is just related to the sqlite implementation.

Relevant log output

No response

Database schema

No response

SQL queries

WITH abc AS (
    SELECT 1 AS n
)
SELECT * FROM abc;

Configuration

No response

Playground URL

Example of it working with postgresql engine: https://play.sqlc.dev/p/aae5b19f0a2bf4f083aa6a0156163225930d12d8ba5cc296f0b54994e2b5ccda

Same code failing when running against the sqlite engine: https://play.sqlc.dev/p/6e6dbf8511ed9ed583b7bb3eac38d57ed43c188921fd9b5b967c3213682f302b

What operating system are you using?

mac

What database engines are you using?

sqlite

What type of code are you generating?

No response

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