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

CASCADE not supported (sqlite) #897

Open sacesare opened 7 years ago

sacesare commented 7 years ago

I've following table in sqlite [TEMP_COMMODITY_UUIDS]:

CREATE TABLE TEMP_COMMODITY_UUIDS (
    ID           INTEGER NOT NULL
                         PRIMARY KEY AUTOINCREMENT
                         REFERENCES COMMODITY (ID) ON DELETE CASCADE,
    UUID         TEXT    NOT NULL,
    BACKEND_UUID TEXT
);

When I try to execute in browser:

alasql([
'ATTACH SQLITE DATABASE db("test.dat");
USE db;
select * from TEMP_COMMODITY_UUIDS'
]).then(function(res){
     console.log("test:",res.pop());
});

I got:

> Uncaught SyntaxError: Parse error on line 1:
...ES COMMODITY(ID) ON DELETE CASCADE, [UUI
-----------------------^
Expecting 'UPDATE', got 'DELETE'
    at Parser.parser.parseError (alasql.js:2210)
    at Parser.parse (alasql.js:2084)
    at Function.alasql.parse (alasql.js:4396)
    at alasql.js:17141
    at Array.forEach (<anonymous>)
    at alasql.js:17138

It seems, alasql.js (0.4.0) can't understand 'ON DELETE CASCADE' construction of sqlite. Similar query, using sql.js directly work just right.

Thanks.

mathiasrw commented 7 years ago

Great input! thanks for taking the time to describe.

Handling CASCADE is not implemented at the moment. Ill set it as a feature request!

ChristopherHButler commented 2 years ago

It seems CASCADE is still not supported in 2022. Is there any plans for this in the near future? Thanks!

mathiasrw commented 2 years ago

@ChristopherHButler We are happy to look at any pull request with this. I have not heard of any people working on this now.