Skip to content

Fix: Add validation for INSERT VALUES with multi-column subqueries - #2402

Merged
mathiasrw merged 7 commits into
developfrom
copilot/fix-typeerror-undefined
Dec 22, 2025
Merged

mathiasrw merged 7 commits into
developfrom
copilot/fix-typeerror-undefined

Conversation

Copilot AI commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor
  • Understand the issue - TypeError when using SELECT in VALUES clause
  • Identify root cause - VALUES with subquery not matching column count
  • Add validation to detect mismatch between columns and values
  • Add proper error message for invalid syntax
  • Create test case for the issue (test1211.js)
  • Verify fix works correctly
  • Run broader tests to ensure no regression
  • Address code review feedback - use template literals
  • Extract duplicated error message into helper function
Original prompt

This section details on the original issue you should resolve

<issue_title>TypeError: Cannot read property 'toJS' of undefined</issue_title>
<issue_description>I'm getting this error when trying run below query

CREATE TABLE t
(
    report_type string,
    inv_qty number,
    week number,
    month number,
    year number
);

INSERT INTO t(report_type,inv_qty,week,month,year) VALUES ((SELECT 'k',1,2,3,4));
SELECT * FROM t;

http://jsfiddle.net/k501hdtg/
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 22, 2025 02:41
Detect mismatch between number of columns and values in INSERT statement.
Provide clear error message directing users to use INSERT...SELECT syntax
instead of INSERT...VALUES with multi-column SELECT subquery.

Co-authored-by: mathiasrw <[email protected]>
Improved code readability by replacing string concatenation
with template literals in error messages.

Co-authored-by: mathiasrw <[email protected]>
Copilot AI changed the title [WIP] Fix TypeError when executing create table query Fix: Add validation for INSERT VALUES with multi-column subqueries Dec 22, 2025
Copilot AI requested a review from mathiasrw December 22, 2025 02:56
Comment thread src/70insert.js Resolved
Comment thread src/70insert.js Resolved
Removed duplication by creating createValueCountMismatchError helper
function that is used in both validation paths (explicit columns and
inferred columns).

Co-authored-by: mathiasrw <[email protected]>
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.

TypeError: Cannot read property 'toJS' of undefined

2 participants