pg-mem
pg-mem copied to clipboard
Self-Alias not found (subquery using alias of its outer query)
https://oguimbal.github.io/pg-mem-playground/
CREATE TABLE my_table (id text NOT NULL PRIMARY KEY, name text NOT NULL, parent_id text);
CREATE INDEX my_table_idx_name ON my_table (name);
CREATE INDEX my_table_idx_id_parent_id ON my_table (id,parent_id);
SELECT * FROM my_table as t1 WHERE t1.name = 'test';
SELECT * FROM my_table as t1 WHERE t1.name = 'test' AND NOT EXISTS (SELECT * FROM my_table as t2 WHERE t2.parent_id = t1.id);
Alias 't1' not found
🐜 This seems to be an execution error, which means that your request syntax seems okay,
but the resulting statement cannot be executed → Probably not a pg-mem error.
*️⃣ Reconsituted failed SQL statement: SELECT * FROM "my_table" AS "t1" WHERE (("t1"."name" = ('test')) AND (NOT ("exists"((SELECT * FROM "my_table" AS "t2" WHERE ("t2"."parent_id" = "t1"."id") )))))
👉 You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and the stacktrace:
FYI I did not forget you :)
#46 is also having this issue...as I told there, I must refactor a bit some things to make this work, and I didnt find the time to do that yet.
Thanks. There is no rush on my end. I have been watching some of the other issues as well and seeing the progress there. But as a fellow OSS maintainer, I know things take time. Don't feel any unnecessary pressure for my sake :)
Just popping in to +1 this. It's impacting my NestJS project as well. As AustinGil said though, take your time. You are doing an amazing job with this library and I am very grateful for all your effort. ^_^
I should've searched existing tickets before submitting mine. Seems test coverage is already done in the new branch, so that's promising. Thanks!
This is affecting me too 😞
+1. Has anybody had a chance to fix this? Or find a workaround?
I decided to use this great project, but my migration framework is based on the queries that use subqueries with alias of the outer query.
@oguimbal Seems like the issue is a little stale, is there a chance you can describe the refactoring problem and pass the issue to the community?
@oguimbal any chance of fixing this issue? 🙏
would it be possible to edit the sql query in the hook? https://github.com/oguimbal/pg-mem#intercept-queries because then I could probably work around this issue