AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.01k stars 653 forks source link

Trigger function does not give changed value in callback #1119

Open umasudhan opened 5 years ago

umasudhan commented 5 years ago

As an example, see the code for Example B at https://github.com/agershun/alasql/wiki/TRIGGER:

alasql.fn.onchange = function(r) {
        if(r.a == 123) console.log('Observable event!');
    };;
    alasql('CREATE TABLE one (a INT)');
    alasql('CREATE TRIGGER two BEFORE INSERT ON one CALL onchange()');
    alasql('INSERT INTO one VALUES (123)');  // This will fire onchange()

Executing this throws an error:

  • TypeError: Cannot read property 'a' of undefined. The parameter r is undefined
mathiasrw commented 4 years ago

This is terrible. Thank you for letting us know.