alasql: DELETE FROM table WHERE error

Using FileStorage and WebWorker. Running the query “DELETE FROM table WHERE column = ‘value’” I get the error:

Uncaught TypeError: Cannot read property 'length' of null(…)
statement   @   alasql.js:12750
alasql.dexec    @   alasql.js:4249
alasql.exec @   alasql.js:4231
alasql  @   alasql.js:120
(anonymous function)    @   VM197:2
InjectedScript._evaluateOn  @   VM144:904
InjectedScript._evaluateAndWrap @   VM144:837
InjectedScript.evaluate @   VM144:693

Subtract 2 from any line after 12747 (I had 2 console.log() for testing).

Code to replicate:

alasql("CREATE TABLE IF NOT EXISTS `preferences` (`id` int(11) NOT NULL, `tab` varchar(45) DEFAULT NULL, `tab_id` int(11))", [], function() {
alasql("INSERT INTO `preferences` (`id`, `tab`, `tab_id`) VALUES (1, 'where', 1), (2, 'when', 8)", [], function() {
alasql('DELETE FROM preferences WHERE tab = "where"')

According to console logs, console.log(table); has no object of data console.log(; returns undefined.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 22 (21 by maintainers)

Most upvoted comments

The table was not populated correctly in the case of filestorage- the attached patch fixes it


I will run through the code some more today. so far, I have found that when using filestorage (I don’t know if this is the same in other engines), but the data is not stored in the db.tables[tableid] object.

I believe that the db is not being read correctly, so db.tables[tableid].data is undefined (where alasql is checking for the item to delete)