-
Notifications
You must be signed in to change notification settings - Fork 688
Fix incorrect result returned for RECORDSET OF query #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7be98d7
Initial plan
Copilot 05df323
Fix RECORDSET OF to include all columns when using wildcard with addi…
Copilot 09e93e8
Address code review comments: improve readability and use strict equa…
Copilot d34d914
Merge branch 'develop' into copilot/fix-recordset-column-retrieval
mathiasrw 24508ac
Apply code formatting with prettier
Copilot c8a00fc
Complete prettier formatting for test293.js
Copilot 1012d4d
Merge branch 'develop' into copilot/fix-recordset-column-retrieval
mathiasrw 79b3b75
Merge branch 'develop' into copilot/fix-recordset-column-retrieval
mathiasrw 5cf3dc5
Rename test file to test2070.js and refactor to use deepEqual assertions
Copilot 77a4db7
Merge branch 'develop' into copilot/fix-recordset-column-retrieval
mathiasrw e15f595
Merge branch 'develop' into copilot/fix-recordset-column-retrieval
mathiasrw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mathiasrw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| if (typeof exports === 'object') { | ||
| var assert = require('assert'); | ||
| var alasql = require('..'); | ||
| } | ||
|
|
||
| describe('Test 2201 - RECORDSET OF with wildcard and additional columns', function () { | ||
| it('1. RECORDSET OF SELECT t.*, additional_column returns all columns', function (done) { | ||
| var data = [ | ||
| {a: 1, b: 10}, | ||
| {a: 2, b: 20}, | ||
| {a: 1, b: 30}, | ||
| ]; | ||
| var res = alasql('RECORDSET OF SELECT t.*, 1 as rn FROM ? t', [data]); | ||
|
|
||
| // Check that all columns are present in the columns array | ||
| assert.equal(res.columns.length, 3, 'Should have 3 columns'); | ||
|
|
||
| var columnIds = res.columns.map(function (col) { | ||
| return col.columnid; | ||
| }); | ||
| assert(columnIds.includes('a'), 'Should include column a'); | ||
| assert(columnIds.includes('b'), 'Should include column b'); | ||
| assert(columnIds.includes('rn'), 'Should include column rn'); | ||
|
|
||
| // Check data integrity | ||
| assert.equal(res.data.length, 3, 'Should have 3 rows'); | ||
| assert.deepEqual(res.data[0], {rn: 1, a: 1, b: 10}); | ||
| assert.deepEqual(res.data[1], {rn: 1, a: 2, b: 20}); | ||
| assert.deepEqual(res.data[2], {rn: 1, a: 1, b: 30}); | ||
|
|
||
| done(); | ||
| }); | ||
|
|
||
| it('2. RECORDSET OF SELECT *, additional_column returns all columns', function (done) { | ||
| var data = [ | ||
| {a: 1, b: 10}, | ||
| {a: 2, b: 20}, | ||
| ]; | ||
| var res = alasql('RECORDSET OF SELECT *, 1 as rn FROM ? t', [data]); | ||
|
|
||
| // Check that all columns are present | ||
| assert.equal(res.columns.length, 3, 'Should have 3 columns'); | ||
|
|
||
| var columnIds = res.columns.map(function (col) { | ||
| return col.columnid; | ||
| }); | ||
| assert(columnIds.includes('a'), 'Should include column a'); | ||
| assert(columnIds.includes('b'), 'Should include column b'); | ||
| assert(columnIds.includes('rn'), 'Should include column rn'); | ||
|
|
||
| done(); | ||
| }); | ||
|
|
||
| it('3. RECORDSET OF SELECT t.* still works correctly', function (done) { | ||
| var data = [ | ||
| {a: 1, b: 10}, | ||
| {a: 2, b: 20}, | ||
| ]; | ||
| var res = alasql('RECORDSET OF SELECT t.* FROM ? t', [data]); | ||
|
|
||
| // Check that all columns are present | ||
| assert.equal(res.columns.length, 2, 'Should have 2 columns'); | ||
|
|
||
| var columnIds = res.columns.map(function (col) { | ||
| return col.columnid; | ||
| }); | ||
| assert(columnIds.includes('a'), 'Should include column a'); | ||
| assert(columnIds.includes('b'), 'Should include column b'); | ||
|
|
||
| done(); | ||
| }); | ||
|
|
||
| it('4. RECORDSET OF SELECT explicit columns works correctly', function (done) { | ||
| var data = [ | ||
| {a: 1, b: 10}, | ||
| {a: 2, b: 20}, | ||
| ]; | ||
| var res = alasql('RECORDSET OF SELECT a, b, 1 as rn FROM ? t', [data]); | ||
|
|
||
| // Check that all columns are present | ||
| assert.equal(res.columns.length, 3, 'Should have 3 columns'); | ||
|
|
||
| var columnIds = res.columns.map(function (col) { | ||
| return col.columnid; | ||
| }); | ||
| assert.deepEqual(columnIds, ['a', 'b', 'rn'], 'Should have columns in order'); | ||
|
|
||
| done(); | ||
| }); | ||
|
|
||
| it('5. RECORDSET OF SELECT with multiple additional columns', function (done) { | ||
| var data = [ | ||
| {a: 1, b: 10}, | ||
| {a: 2, b: 20}, | ||
| ]; | ||
| var res = alasql('RECORDSET OF SELECT t.*, 1 as rn, 2 as seq FROM ? t', [data]); | ||
|
|
||
| // Check that all columns are present | ||
| assert.equal(res.columns.length, 4, 'Should have 4 columns'); | ||
|
|
||
| var columnIds = res.columns.map(function (col) { | ||
| return col.columnid; | ||
| }); | ||
| assert(columnIds.includes('a'), 'Should include column a'); | ||
| assert(columnIds.includes('b'), 'Should include column b'); | ||
| assert(columnIds.includes('rn'), 'Should include column rn'); | ||
| assert(columnIds.includes('seq'), 'Should include column seq'); | ||
|
|
||
| // Check data | ||
| assert.deepEqual(res.data[0], {rn: 1, seq: 2, a: 1, b: 10}); | ||
|
|
||
| done(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.