-
Notifications
You must be signed in to change notification settings - Fork 693
[WIP] Implement MERGE statement execution logic #2410
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
base: develop
Are you sure you want to change the base?
Changes from 6 commits
a7ffca9
8fb3bee
08919ab
3703539
1da241a
ddd567e
a931227
5d4b63b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
mathiasrw marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,11 +61,29 @@ describe('Test 236 MERGE', function () { | |
|
|
||
| */ | ||
| } | ||
| .toString() | ||
| .slice(14, -3); | ||
| /// console.log(alasql.parse(sql).toString()); | ||
| .toString(); | ||
|
|
||
| // Extract SQL from comment | ||
| var start = sql.indexOf('/*') + 2; | ||
| var end = sql.lastIndexOf('*/'); | ||
| sql = sql.substring(start, end).trim(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is going on here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines 67-69 extract SQL from a multiline comment embedded in a function. The pattern:
I've added clearer comments in commit a931227 to explain this pattern. |
||
|
|
||
| // Execute the MERGE | ||
| var res = alasql(sql); | ||
|
|
||
| // Verify result count (3 rows affected: 1 insert + 2 deletes) | ||
| assert.equal(res, 3); | ||
|
|
||
| // Verify final table state | ||
| var target = alasql('SELECT * FROM [Target] ORDER BY EmployeeID'); | ||
| assert.deepEqual(target, [ | ||
| {EmployeeID: 100, EmployeeName: 'Mary'}, // Unchanged (not in source, not matching S%) | ||
| // 101 'Sara' deleted (not in source, matches S%) | ||
| // 102 'Stefano' deleted (not in source, matches S%) | ||
| // 103 'Bob' not inserted (in source but doesn't match S%) | ||
| {EmployeeID: 104, EmployeeName: 'Steve'}, // Inserted (not in target, matches S%) | ||
| ]); | ||
|
|
||
| // console.log(res); | ||
| done(); | ||
| }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.