Skip to content

Fix multi-level nested scalar subquery evaluation - #2550

Draft
mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/fix-third-level-subquery-error
Draft

mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/fix-third-level-subquery-error

Conversation

Copilot AI commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Nested scalar subqueries deeper than two levels failed at runtime because inner selects resolved queriesidx against a missing queriesfn.

Changes

  • compileQueries: share the compiled subquery list down the tree so multi-level scalar selects can resolve this.queriesfn[queriesidx - 1]
  • Nested IN path: avoid overwriting a queriesfn already built during nested compile()
  • test/test1025.js: regression coverage for 2–4 level scalar nesting, derived tables, and nested scalars inside IN

Example

-- previously threw: Cannot read properties of undefined (reading '0')
SELECT (SELECT (SELECT 1 AS c) AS b) AS a;
-- => [{ a: 1 }]

Copilot AI changed the title [WIP] Fix third level of subquery result in error Fix multi-level nested scalar subquery evaluation Sep 10, 2026
Copilot AI requested a review from mathiasrw September 10, 2026 13:23
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.

Third level of subquery result in error

2 participants