Skip to content

Run the ON functions of a join with the query as this so a subquery in ON works to close #2795 - #2992

Merged
mathiasrw merged 3 commits into
AlaSQL:developfrom
mateuscmtropical:fix-2795-subquery-in-join-on
Nov 17, 2026
Merged

mathiasrw merged 3 commits into
AlaSQL:developfrom
mateuscmtropical:fix-2795-subquery-in-join-on

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2795

A subquery in the ON of a JOIN threw TypeError: ... evaluating 'this.queriesfn[0]'. The compiled ON functions were called as methods of the source (source.onmiddlefn(...)), so this was the source and not the query. WHERE runs as query.wherefn(...), so a subquery there finds this.queriesfn.

src/39dojoin.js and src/38query.js now call the join functions (onleftfn, onrightfn, onmiddlefn and srcwherefn) with the query as this. The generated code is unchanged.

test/test2795.js covers LEFT JOIN and JOIN with a subquery next to the key condition, a subquery that reads the joined row, and a subquery as the only condition. The tests fail on develop and pass with the change. yarn test-only gives 2555 pass. The only failures are the 5 Test 418 cases that load data from the internet, and they fail the same way on develop in my environment.

@mathiasrw
mathiasrw merged commit 43b87e0 into AlaSQL:develop Nov 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LEFT JOIN with a subquery in ON throws a TypeError

2 participants