-
Notifications
You must be signed in to change notification settings - Fork 688
Add parser support for ON DELETE and ON UPDATE CASCADE in REFERENCES #2311
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?
Conversation
|
@copilot Plesae continye |
Completed! Added support for ON DELETE and ON UPDATE CASCADE (and other referential actions: SET NULL, SET DEFAULT, RESTRICT, NO ACTION) for both column-level and table-level FOREIGN KEY constraints. The parser now correctly handles the syntax from the issue. All tests pass. Commit: 7302433 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
mathiasrw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Run yarn test-format-all |
|
@copilot continue |
| } | ||
| function i(n, r) { | ||
| ((n[r >> 5] |= 128 << r % 32), (n[(((r + 64) >>> 9) << 4) + 14] = r)); | ||
| ((n[r >> 5] |= 128 << (r % 32)), (n[(((r + 64) >>> 9) << 4) + 14] = r)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed?
| r = []; | ||
| for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1) r[t] = 0; | ||
| for (t = 0; t < 8 * n.length; t += 8) r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; | ||
| for (t = 0; t < 8 * n.length; t += 8) r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << (t % 32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed?
|
Can you make a new issue describing what needs to be done to fix
|
I don't have the ability to create new GitHub issues directly. However, I can provide the content for a new issue that describes what needs to be implemented: Title: Implement CASCADE behavior enforcement for FOREIGN KEY constraints Description: What needs to be implemented:
Implementation areas:
Related: PR #[current PR number], Issue #897 |
3240b4f to
c871517
Compare
Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
…CASCADE tests Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
1908f66 to
e734489
Compare
…a verification Co-authored-by: mathiasrw <[email protected]>
Thank you for the time you are putting into AlaSQL!
Description
This PR adds parser support for ON DELETE and ON UPDATE referential actions in FOREIGN KEY constraints, fixing issue #897.
The parser previously threw an error "Expecting 'UPDATE', got 'DELETE'" when encountering
ON DELETE CASCADEsyntax in REFERENCES clauses. This has been resolved by implementing comprehensive support for all standard SQL referential actions.Note: AlaSQL currently parses but does not enforce CASCADE behavior. This means that while the syntax is now accepted for SQL-99 compatibility, deleting parent rows will not automatically delete or update child rows. The implementation provides syntax compatibility without behavioral enforcement.
Changes Made
Parser Modifications (
src/alasqlparser.jison)ReferentialAction: Handles CASCADE, SET NULL, SET DEFAULT, RESTRICT, NO ACTIONOnDeleteClause: Handles ON DELETE <action>OnUpdateClause: Handles ON UPDATE <action>OnReferentialActions: Combines ON DELETE and ON UPDATE in any order or individuallyTest Coverage (
test/test897.js)Created comprehensive test suite with 20 tests covering:
assert.deepEqual()to validate entire result objects against expected valuesSupported Syntax
The parser now correctly handles all these patterns:
Testing
assert.deepEqual()for comprehensive validation of complete result setsThe changes maintain full SQL-99 syntax compliance for referential integrity while preserving complete backward compatibility with existing code.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.