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
LEFT JOIN with a subquery in ON throws a TypeError #2795
A subquery in the ON condition of a LEFT JOIN throws a TypeError.
Seen in the NIST SQL Test Suite run in dml148.sql: SELECT XX.PNUM, BUDGET, HOURS, EMPNUM FROM HU.PROJ XX LEFT JOIN HU.WORKS YY ON XX.PNUM = YY.PNUM AND HOURS * BUDGET / 160000 > (SELECT GRADE FROM HU.STAFF WHERE YY.EMPNUM = HU.STAFF.EMPNUM). Reproduced on develop (38bf3c3):
alasql("CREATE TABLE staff (empnum CHAR(3), grade INT)");alasql("INSERT INTO staff VALUES ('E1', 12), ('E2', 10)");alasql("CREATE TABLE works (empnum CHAR(3), hours INT)");alasql("INSERT INTO works VALUES ('E1', 40), ('E2', 20)");alasql('SELECT s.empnum, w.hours FROM staff s LEFT JOIN works w ON s.empnum = w.empnum AND w.hours > (SELECT MIN(hours) FROM works)');// TypeError: undefined is not an object (evaluating 'this.queriesfn[0]')
Expected: [{empnum: 'E1', hours: 40}, {empnum: 'E2'}] (no match for E2, so hours is NULL).
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: #2992
Fix ON functions for JOIN subquery to close AlaSQL#2795 (AlaSQL#2992)