Skip to content

Commit

Permalink
db.sqlite: fix the delete constraint for the restrict case
Browse files Browse the repository at this point in the history
  • Loading branch information
bjourne committed Aug 25, 2016
1 parent 66083e2 commit ebdf57d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion basis/db/sqlite/sqlite-tests.factor
Expand Up @@ -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
} [
{
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion basis/db/sqlite/sqlite.factor
Expand Up @@ -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 ;

Expand Down

0 comments on commit ebdf57d

Please sign in to comment.