Skip to content

Define renameColumns for WITH column lists to close #2841 - #2983

Open
mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2841-with-column-list
Open

mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2841-with-column-list

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2841

src/67withselect.js called renameColumns for a WITH entry with a column list, but the function was never declared, so WITH t(a) AS (SELECT 1 AS x) SELECT a FROM t threw ReferenceError: renameColumns is not defined.

This adds renameColumns next to mapColumnsToNames and uses it to rename the columns by position, the same way the recursive UNION branch does. The positions come from the keys of the first row, which follow the order of the select's columns. A column list shorter or longer than the select is handled like in the recursive branch: extra names or extra columns are dropped.

test/test2841.js covers a single column, renaming by position, SELECT * and an expression in a second CTE, an empty CTE, a recursive CTE without UNION, and the callback form. All of them fail on develop with the ReferenceError and pass with the change. yarn test-only gives 2557 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.

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.

WITH t(a) AS (SELECT ...) throws ReferenceError: renameColumns is not defined

2 participants