]> gitweb.factorcode.org Git - factor.git/commitdiff
db.sqlite: fix the delete constraint for the restrict case
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 25 Aug 2016 11:52:44 +0000 (13:52 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Thu, 25 Aug 2016 11:52:44 +0000 (13:52 +0200)
basis/db/sqlite/sqlite-tests.factor
basis/db/sqlite/sqlite.factor

index 89a92621ddba782b8e779ec53544c5771aa13536..c44c6219147125012bc116fa70fc2ee63adb3f61 100644 (file)
@@ -15,7 +15,7 @@ ${
         "SELECT RAISE(ROLLBACK, "
                       "'delete on table \"NODE\" violates "
                       "foreign key constraint \"fkd_TREE_NODE_NODE_ID_id\"') "
-        "WHERE (SELECT ID FROM NODE WHERE ID = OLD.ID) IS NOT NULL; END;"
+        "WHERE (SELECT NODE FROM TREE WHERE NODE = OLD.ID) IS NOT NULL; END;"
     } concat
 } [
     {
@@ -203,6 +203,7 @@ watch "WATCH" {
         watch boa insert-tuple
         watch new select-tuple
         user>> f user boa select-tuple
+        user new "mark" >>username delete-tuples
     ] with-db
 ] unit-test
 
index 6ffe285522b807db85049fa6152253cee0bf920a..62b4bde10528ae550038d51542c919a3ce033105 100644 (file)
@@ -243,7 +243,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
         BEFORE DELETE ON ${foreign-table-name}
         FOR EACH ROW BEGIN
             SELECT RAISE(ROLLBACK, 'delete on table \"${foreign-table-name}\" violates foreign key constraint \"fkd_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id\"')
-            WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = OLD.${foreign-table-id}) IS NOT NULL;
+            WHERE (SELECT ${table-id} FROM ${table-name} WHERE ${table-id} = OLD.${foreign-table-id}) IS NOT NULL;
         END;
     " interpolate>string ;