Skip to content

Harden DELETE/UPDATE trigger edge cases and expand test coverage - #2552

Draft
mathiasrw with Copilot wants to merge 2 commits into
developfrom
copilot/triggers-database-event-automation-support
Draft

mathiasrw with Copilot wants to merge 2 commits into
developfrom
copilot/triggers-database-event-automation-support

Conversation

Copilot AI commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

CREATE TRIGGER CALL already passed row data for basic INSERT/UPDATE/DELETE cases, but DELETE ignored prevent/INSTEAD OF outcomes and AFTER UPDATE passed the new row twice.

Changes

  • DELETE: Honor table.delete() === false for BEFORE prevent and INSTEAD OF so matching rows stay in the table and skip AFTER DELETE / OUTPUT
  • INSTEAD OF DELETE: Return false from table.delete so callers treat it like a prevented delete
  • AFTER UPDATE: Capture the pre-update row and pass (oldRow, newRow) to triggers
  • Tests: Extend test/test1119.js for AFTER UPDATE, prevent-delete, and INSTEAD OF DELETE
alasql.fn.onUpdate = function (oldRow, newRow) {
  // oldRow.a === 10, newRow.a === 20
};
alasql('CREATE TRIGGER t AFTER UPDATE ON six CALL onUpdate()');
alasql('UPDATE six SET a = 20 WHERE a = 10');

alasql.fn.block = function () { return false; };
alasql('CREATE TRIGGER t2 BEFORE DELETE ON seven CALL block()');
alasql('DELETE FROM seven WHERE a = 1'); // row kept

Copilot AI linked an issue Sep 10, 2026 that may be closed by this pull request
8 tasks
Copilot AI changed the title [WIP] Add SQL-99 compliance for trigger functionality Harden DELETE/UPDATE trigger edge cases and expand test coverage Sep 10, 2026
Copilot AI requested a review from mathiasrw September 10, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triggers - Database Event Automation Support

2 participants