Skip to content
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

With Recursive query results in "no relation" error with SQLite #3730

Open
zilllaiss opened this issue Nov 29, 2024 · 0 comments
Open

With Recursive query results in "no relation" error with SQLite #3730

zilllaiss opened this issue Nov 29, 2024 · 0 comments
Labels
📚 sqlite bug Something isn't working 💻 linux

Comments

@zilllaiss
Copy link

Version

1.27.0

What happened?

WIth Recursive query fails to recognize the relation in SQLite when I run sqlc generate.

not sure if this works with SQLite, but I tried adding this to config, but it didn't work.

datebase:
    managed: true

I'm aware of #723 and #896, and it seems the fix only applies to PostgreSQL + MySQL. But perhaps this bug is more relevant with #2990 even though it happens with MySQL instead.

Relevant log output

# package db
query.sql:1:1: relation "TagWithParents" does not exist

Database schema

CREATE TABLE tags (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    parent INTEGER NOT NULL
);

SQL queries

-- name: GetTagRecursive :many
WITH RECURSIVE TagWithParents AS (
    SELECT id, name, parent
    FROM tags
    WHERE id = ?

    UNION ALL

    SELECT t.id, t.name, t.parent
    FROM tags t
    INNER JOIN TagWithParents twp
    ON t.id = twp.parent
) SELECT * FROM TagWithParents;

Configuration

version: "2" 

sql: 
  - engine: "sqlite" 
    queries: "query.sql" 
    schema: "schema.sql" 
    gen: 
      go: 
        package: "db" 
        out: "db"

Playground URL

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

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

@zilllaiss zilllaiss added the bug Something isn't working label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 sqlite bug Something isn't working 💻 linux
Projects
None yet
Development

No branches or pull requests

1 participant