Skip to content

Run the table function of FROM with the query as this to close #3203 - #3207

Open
arsalankhan786777 wants to merge 1 commit into
AlaSQL:mainfrom
arsalankhan786777:fix/3203-tablefn-subquery
Open

arsalankhan786777 wants to merge 1 commit into
AlaSQL:mainfrom
arsalankhan786777:fix/3203-tablefn-subquery

Conversation

@arsalankhan786777

Copy link
Copy Markdown
Contributor

A subquery, IN or EXISTS in an argument of a table function in FROM, such as RANGE(1, (SELECT MAX(x) FROM u)), threw TypeError: Cannot read properties of undefined (reading '0'). The code of the argument reads this.queriesfn, but the function that reads the source ran with the source as this, and a source has no queriesfn.

queryfn.js now calls source.datafn with the query as this, as WHERE and ON do. No source function uses this, so nothing else changes.

Fixes #3203

Tested:

  • New test/test3203.js (6 tests): the three statements of the issue, a subquery in the first argument, in a subquery in FROM, and with a ? parameter. All 6 fail before the change and pass after.
  • Full bun test --preload ./test/bun-setup.js ./test/test[0-9]*.js ./test/test-*.js: 10 failures (Excel 107-B, test2979 D, two CLI piped-input tests), the same 10 on unchanged main.
  • prettier --list-different on the two files: clean.

Written with Claude Code (AI); tested locally with bun 1.4.2 (bun test on the built dist) and prettier

🤖 Generated with Claude Code

…#3203

A subquery, IN or EXISTS in an argument of a table function in FROM
(RANGE(1, (SELECT MAX(x) FROM u))) read this.queriesfn, but the
function that reads the source ran with the source as this, so it
threw a TypeError. Run it with the query as this, as WHERE and ON do.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

A subquery in an argument of a table function in FROM throws a TypeError: RANGE(1, (SELECT ...))

1 participant