Fix SQL-99 trigger CALL syntax to pass row data parameters #2377
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.
Fixes SQL-99 trigger functionality to properly pass row data when using the
CALL funcname()syntax. The trigger framework (parser, registration, execution timing) was already implemented, but the CALL syntax wasn't extracting function IDs correctly or passing row parameters.Problem
Triggers created with
CREATE TRIGGER ... CALL funcname()were being invoked but receivedundefinedinstead of row data. This affected all trigger types across INSERT, UPDATE, and DELETE operations.Changes Made
1. Fixed Parameter Passing for All Trigger Types
2. Refactored for Maintainability
alasql.executeTrigger()helper function insrc/71trigger.js3. Files Modified
src/71trigger.js: Addedalasql.executeTrigger()helper functionsrc/60createtable.js: Updated INSERT, UPDATE, DELETE trigger execution intable.insert(),table.update(), andtable.delete()src/72delete.js: Fixed AFTER DELETE trigger execution with row-level datatest/test1119.js: Enabled trigger tests (removed.skip)Test Results
✅ 5/5 trigger tests passing in test1119.js:
✅ 37 tests passing including all basic INSERT/UPDATE/DELETE tests with no regressions
Code Quality
Implementation Notes
...args) consistent with existing codebaseOriginal prompt
This section details on the original issue you should resolve
<issue_title>Triggers - Database Event Automation Support</issue_title>
<issue_description>Priority: 3-4 (Medium)
Impact: SQL-99 Compliance
Test Files:
test/test1119.jsTest Count: 1 test
Problem Description
The test file contains skipped tests for SQL trigger functionality including BEFORE, AFTER, and INSTEAD OF triggers for INSERT, UPDATE, and DELETE operations. Triggers are essential SQL-99 features for database automation and business logic enforcement.
Specific Test Cases
test1119.js - Trigger Callback Parameters (1 test suite)
Expected Behavior
AlaSQL should support SQL-99 standard trigger functionality:
Current Status
describe.skip)Implementation Requirements
1. Parser Support
Add trigger syntax to
src/alasqlparser.jison:2. Trigger Engine
3. Trigger Types Support
4. Data Parameter Support
5. Advanced Features
SQL-99 Features Involved
Dependencies
src/alasqlparser.jison)alasql.fn)Acceptance Criteria
Basic Trigger Functionality (test1119.js)
Implementation Strategy
Phase 1: Basic Trigger Framework
Phase 2: Trigger Types and Parameters
Phase 3: Advanced Features
Test Implementation Examples