Add parser support for ON DELETE and ON UPDATE CASCADE in REFERENCES#2311
Add parser support for ON DELETE and ON UPDATE CASCADE in REFERENCES#2311
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:
|
|
Run yarn test-format-all |
|
@copilot continue |
|
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 |
85c2df4 to
6279774
Compare
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
…CASCADE tests Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
6279774 to
e0a7021
Compare
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.