alasql: DELETE not working without WHERE xxx

delete from statement dont work if i dont add where. so I had to do work around like ‘delete from SomeKindOfTable where 1=1’

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Sorry, Still not working for me Uncaught TypeError: Cannot read property ‘tables’ of undefined at Function.LS.storeTable (alasql.js:16717) at Function.LS.saveTableData (alasql.js:17032) at statement (alasql.js:13326) at Function.alasql.dexec (alasql.js:4575) at Function.alasql.exec (alasql.js:4557) at alasql (alasql.js:133) at <anonymous>:1:1 LS.storeTable @ alasql.js:16717 LS.saveTableData @ alasql.js:17032 statement @ alasql.js:13326 alasql.dexec @ alasql.js:4575 alasql.exec @ alasql.js:4557 alasql @ alasql.js:133 (anonymous) @ VM68:1

Oh man, and this statement does not work:

DELETE FROM arzt_art WHERE 1=1 and FKEY LIKE “NEU%”

image

We had to change the cases in columns and now run into a problem…

Getting error using ‘DELETE FROM arzt_art WHERE fkey LIKE “NEU%”"’ on IndexedDB. Using v1.7.3

Uncaught TypeError: Cannot read properties of undefined (reading ‘utils’) at k.Delete.eval (eval at k.Delete.compile (alasql.min.js:2:390735), <anonymous>:3:100) at e.onsuccess (alasql.min.js:2:431858)

This error occurs only if the table has data in it. Using the above statement on an empty table is working.

image

Did I miss to require a .js library ? I only included alasql.min.js.

SOLUTION DELETE FROM arzt_art WHERE 1=1 and fkey LIKE “NEU%” works also here

https://github.com/agershun/alasql/blob/7c528a44b9f01b170f764a95d338576bf894ae99/src/72delete.js#L110 it seems a conditions is missing here: “&& db.engineid == ‘LOCALSTORAGE’)” because a request like ‘DELETE FROM table;’ cause this issue: TypeError: alasql.engines[db.engineid].loadTableData is not a function

Can you send PR to a wiki on github? Sure - bring it ON!

For sure!

The code base is the beast here… not SQL or JS.

Lets work on it together.

As a start I suggest that you follow the first steps in https://github.com/agershun/alasql/blob/develop/CONTRIBUTING.md until you have a new test that fails and then make a PR so we can have a good place to talk about things.

Future input: I have a feeling we have to find out if https://github.com/agershun/alasql/blob/7c528a44b9f01b170f764a95d338576bf894ae99/src/72delete.js#L25 is true even if no WHERE was set…

Thanks for letting us know. Its really good that you check things like this so the library can get better!