-
Notifications
You must be signed in to change notification settings - Fork 689
Fix NULL value handling in SELECT * INTO SQL() #2196
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 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
de047c6
Initial plan
Copilot d1b867d
Add test for NULL values in INTO SQL() - confirms issue exists
Copilot cc04534
Fix NULL values in INTO SQL() - handle null and undefined properly
Copilot ccb9ffc
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw 94507b7
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw 35acc64
Fix code formatting for test042_null_issue.js
Copilot 4846eb0
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw 31da433
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw 6e45809
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw ec64f1c
Refactor tests: remove console.log, use deepEqual, arrow functions
Copilot 210b87a
Refactor switch statement to include default case
Copilot 85a079a
Refactor: simplify if-else to use else-if for cleaner code
Copilot 0961606
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw 616a97e
Refactor: eliminate code repetition by consolidating escape logic
Copilot 33ed6b5
Merge branch 'develop' into copilot/fix-null-value-insertion
mathiasrw ba35f5e
Rename test file to test42.js and update test name to "Test 42"
Copilot 85e372d
Merge branch 'develop' into copilot/fix-null-value-insertion
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
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,45 @@ | ||
| if (typeof exports === 'object') { | ||
| var assert = require('assert'); | ||
| var alasql = require('..'); | ||
| } | ||
|
|
||
| describe('Test 042 - NULL values in INTO SQL()', function () { | ||
| it('1. Should output NULL for null values', () => { | ||
| var data = [ | ||
| {a: 1, b: 'test', c: null, d: 3}, | ||
| {a: 2, b: null, c: 4, d: null}, | ||
| {a: null, b: 'value', c: null, d: null}, | ||
| ]; | ||
| var res = alasql('SELECT * INTO SQL({tableid:"test_table"}) FROM ?', [data]); | ||
|
|
||
| var expected = | ||
| "INSERT INTO test_table(a,b,c,d) VALUES (1,'test',NULL,3);\n" + | ||
| 'INSERT INTO test_table(a,b,c,d) VALUES (2,NULL,4,NULL);\n' + | ||
| "INSERT INTO test_table(a,b,c,d) VALUES (NULL,'value',NULL,NULL);\n"; | ||
|
|
||
| assert.deepEqual(res, expected); | ||
| }); | ||
|
|
||
| it('2. Should handle undefined values as NULL', () => { | ||
| var data = [ | ||
| {a: 1, b: 'test'}, | ||
| {a: 2, b: undefined, c: 4}, | ||
| ]; | ||
| var res = alasql('SELECT * INTO SQL({tableid:"test_table"}) FROM ?', [data]); | ||
|
|
||
| var expected = | ||
| "INSERT INTO test_table(a,b) VALUES (1,'test');\n" + | ||
| 'INSERT INTO test_table(a,b) VALUES (2,NULL);\n'; | ||
|
|
||
| assert.deepEqual(res, expected); | ||
| }); | ||
|
|
||
| it('3. Should handle mixed NULL, undefined, and empty strings', () => { | ||
| var data = [{a: 1, b: '', c: null, d: undefined}]; | ||
| var res = alasql('SELECT * INTO SQL({tableid:"test_table"}) FROM ?', [data]); | ||
|
|
||
| var expected = "INSERT INTO test_table(a,b,c,d) VALUES (1,'',NULL,NULL);\n"; | ||
|
|
||
| assert.deepEqual(res, expected); | ||
| }); | ||
| }); | ||
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.