-
Notifications
You must be signed in to change notification settings - Fork 802
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
CTE with RECURSIVE column does not exist #723
Comments
This looks related to #709 |
@kindermoumoute playing with aliases names didn't help. I saw #709 issue before posting this. |
Alias didn't help for me too, I have no idea why it worked for @jschaf 🤷♂️ |
I wasn't doing a recursive CTE. |
The below example will result in an error CREATE TABLE foo (
key uuid DEFAULT public.uuid_generate_v4() NOT NULL,
modification_date timestamp with time zone DEFAULT now() NOT NULL
); -- name: FooBar :many
WITH agg1 AS (
SELECT t.key, t.modification_date as modified_at FROM foo t
)
SELECT key FROM agg1 WHERE modified_at > @from_date; All aliases I tried failed but the original name works: -- name: FooBar :many
WITH agg1 AS (
SELECT t.key, t.modification_date as modification_date FROM foo t
)
SELECT key FROM agg1 WHERE modification_date > @from_date; Error comes from this line so I would suggest the sqlc code is not indexing aliases from the WITH. Maybe @kyleconroy has some additional inputs on this? |
Maybe try a fully qualified reference or using a table alias? I have a pretty complex query with 5 CTEs that works and I'm using table aliases for each CTE. In general, I've found being painfully explicit with aliases and casting sometimes helps sqlc work through the query. I also use this syntax for params: |
This commit adds support for `UNION` in `internal/compiler`. It also adds test cases for `UNION` in a `SELECT` and in a `WITH RECURSIVE` query. It fixes sqlc-dev#568, sqlc-dev#723 and sqlc-dev#778.
This commit adds support for `UNION` in `internal/compiler`. It also adds test cases for `UNION` in a `SELECT` and in a `WITH RECURSIVE` query. It fixes sqlc-dev#568, sqlc-dev#723 and sqlc-dev#778.
This commit adds support for `UNION` in `internal/compiler`. It also adds test cases for `UNION` in a `SELECT` and in a `WITH RECURSIVE` query. It fixes sqlc-dev#568, sqlc-dev#723 and sqlc-dev#778.
This commit adds support for UNION query in the compiler. It adds test cases for UNION in a SELECT and in a recursive CTE. It fixes sqlc-dev#568, sqlc-dev#723 and sqlc-dev#778.
Fixed in #896 |
I believe I ran into this same issue with on sqlc v1.10.0. Playground link: https://play.sqlc.dev/p/0ab785e6d5aaadf734521e870a8140399e767f8ecec6ba8934a421f40c440ec9 |
sqlc.yaml
schema.sql
query.sql
sqlc generate
gives meThe text was updated successfully, but these errors were encountered: