You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A correlated subquery that is a UNION throws a TypeError #2856
A correlated subquery that is a UNION throws a TypeError when a branch refers to the outer table. The same subquery without UNION works.
Seen in the MySQL server tests run (alasql-mysqltest): 84 statements in 10 files (subquery_all.test and the files that include subquery.inc), for example select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2. Reproduced with alasql 4.21.0:
alasql('CREATE TABLE t1 (a INT)');alasql('INSERT INTO t1 VALUES (1), (2), (3)');alasql('CREATE TABLE t2 (a INT, c INT)');alasql('INSERT INTO t2 VALUES (1, 5), (2, 6)');alasql('SELECT a, (SELECT c FROM t2 WHERE t2.a = t1.a) AS x FROM t1');// worksalasql('SELECT a, (SELECT c FROM t2 WHERE t2.a = t1.a UNION SELECT c FROM t2 WHERE t2.a = t1.a) AS x FROM t1');// TypeError: undefined is not an object (evaluating 'p['t1']['a']')alasql('SELECT a FROM t1 WHERE EXISTS (SELECT c FROM t2 WHERE c = 1 UNION SELECT c FROM t2 WHERE t2.a = t1.a)');// the same TypeError
Expected: x is 5, 6 and NULL; the EXISTS query gives 1 and 2.
Activity
mateuscmtropical commentedon Nov 11, 2026
Hi, I'd like to work on this one.
mateuscmtropical commentedon Nov 11, 2026
Hi, I've opened a PR for this: #2990
Fix SET operation in a correlated subquery to close AlaSQL#2856 (AlaS…
Check set operations after a parenthesized chain when detecting corre…