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
6.98k stars 649 forks source link

`CURRENT_TIMESTAMP`, `NOW`, and other standard functions do not work: `alasql is not defined` #1847

Closed arximboldi closed 7 months ago

arximboldi commented 7 months ago

When I try to run standard functions like in:

    await alasql.promise(INSERT INTO pigs (id, timestamp) VALUES (?, CURRENT_TIMESTAMP)', [id]);

Then I get an internal error:

Unhandled error: ReferenceError: alasql is not defined
    at eval (eval at statement (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:14430:13), <anonymous>:3:80)
    at statement (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:14430:69)
    at alasql.dexec (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:4720:28)
    at alasql.exec (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:4664:17)
    at alasql (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:137:16)
    at /home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:4864:3
    at new Promise (<anonymous>)
    at promiseExec (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:4863:9)
    at alasql.promise (/home/raskolnikov/dev/cerditos/server/node_modules/alasql/dist/alasql.fs.js:4932:10)
    at /home/raskolnikov/dev/cerditos/server/routes/api.js:104:11

This has been tested at least with the two functions above.

arximboldi commented 7 months ago

Workaround for this particular instance:

    await alasql.promise(INSERT INTO pigs (id, timestamp) VALUES (?, ?)', [id, new Date()]);
mathiasrw commented 7 months ago

Thank you for sharing.