question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Self-Alias not found (subquery using alias of its outer query)

See original GitHub issue

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:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Feb 15, 2021

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. ^_^

3reactions
shahyarcommented, Feb 22, 2021

I should’ve searched existing tickets before submitting mine. Seems test coverage is already done in the new branch, so that’s promising. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

subquery in FROM must have an alias - Stack Overflow
I have a similar query in Oracle that works fine. The only change is where I have EXCEPT in Oracle I have replaced...
Read more >
How to Fix The "Every derived table must have its own alias ...
The short answer is you need to give your subqueries an alias in your SELECT statement. Add an alias after the closing bracket...
Read more >
How to Use Aliases in SQL Queries - LearnSQL.com
There are several ways to use aliases in your SQL queries. This article shows you how, using simple explanations and helpful examples.
Read more >
Query syntax | BigQuery - Google Cloud
query_expr. ( query_expr ) [ [ AS ] alias ] is a table subquery. ... If no rule is available for any STRUCT...
Read more >
U115: Subquery in FROM must have an alias - pganalyze
The correct fix is to give the subquery in the FROM clause an alias (i.e. a name), so that it can be uniquely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found