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

postgresql: unable to use unnest(...) in subquery #5346

Open
wreedamz opened this issue Jul 11, 2024 · 0 comments
Open

postgresql: unable to use unnest(...) in subquery #5346

wreedamz opened this issue Jul 11, 2024 · 0 comments
Labels

Comments

@wreedamz
Copy link

SQLDelight Version

2.0.2

SQLDelight Dialect

postgresql

Describe the Bug

given the schema

CREATE TABLE IF NOT EXISTS business(
    businessId SERIAL PRIMARY KEY,
    name TEXT NOT NULL,
    locations TEXT[] NOT NULL
);

i am unable to perform a query to search for businesses that have a keyword in their location:

SELECT *
FROM business
WHERE EXISTS (
    SELECT 1
    FROM unnest(locations) as loc
    WHERE lower(loc) LIKE '%' || LOWER(:query) || '%'
);

this gives me the error

/Users/wreedamz/d/sql-delight-blank/src/main/sqldelight/com/foo/Student.sq: (7, 15): ')', ',', '.', <compound operator real>, <join operator real>, <table alias real>, AS, FOR, GROUP, HAVING, INDEXED, LIMIT, NOT, OFFSET, ORDER or WHERE expected, got '('
3    SELECT *
4    FROM business
5    WHERE EXISTS (
6        SELECT 1
7        FROM unnest(locations) as loc
                    ^
8        WHERE lower(loc) LIKE '%' || LOWER(:query) || '%'
9    )

sample repository here

Stacktrace

No response

@wreedamz wreedamz added the bug label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant