Skip to content

Drop trigger throws error #1113

@umasudhan

Description

@umasudhan

The following program creates a table and a trigger on the table. An error is thrown when the trigger is dropped.

const alasql = require('alasql');
alasql.fn.onchange = function(r) {
    console.log('got event in trigger callback 1');
};
alasql('CREATE TABLE one (a INT)');
alasql('CREATE TRIGGER myTrigger AFTER INSERT ON one CALL onchange()');
alasql('INSERT INTO one VALUES (123)');  // This will fire onchange()
alasql('DROP TRIGGER myTrigger');
alasql('INSERT INTO one VALUES (231)');  // This should not fire onchange()
**Stacktrace:**
got event in trigger callback 1
<path>\node_modules\alasql\dist\alasql.fs.js:14848
		delete db.tables[tableid].beforeinsert[triggerid];
		                          ^
TypeError: Cannot read property 'beforeinsert' of undefined
    at yy.DropTrigger.execute (<path>\node_modules\alasql\dist\alasql.fs.js:14848:29)
    at Function.alasql.dexec (<path>\node_modules\alasql\dist\alasql.fs.js:4659:46)
    at Function.alasql.exec (<path>\node_modules\alasql\dist\alasql.fs.js:4607:17)
    at alasql (<path>\node_modules\alasql\dist\alasql.fs.js:138:16)
    at Object.<anonymous> (<path>\test9.js:8:1)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions