From 1a16f085d083ddfc996d9c4e312d6e687db9161d Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 30 Nov 2015 20:42:14 +0100 Subject: [PATCH] core (sqlite storage): do explicit delete to profile linked tables for deleteProfile --- src/memory/sqlite.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/memory/sqlite.py b/src/memory/sqlite.py index 70ebcfa8..de5fb727 100644 --- a/src/memory/sqlite.py +++ b/src/memory/sqlite.py @@ -174,9 +174,16 @@ class SqliteStorage(object): return failure def delete(txn): - del self.profiles[name] + profile_id = self.profiles.pop(name) txn.execute("PRAGMA foreign_keys = ON") txn.execute("DELETE FROM profiles WHERE name = ?", (name,)) + # FIXME: the following queries should be done by the ON DELETE CASCADE + # but it seems they are not, so we explicitly do them by security + # this need more investigation + txn.execute("DELETE FROM history WHERE profile_id = ?", (profile_id,)) + txn.execute("DELETE FROM param_ind WHERE profile_id = ?", (profile_id,)) + txn.execute("DELETE FROM private_ind WHERE profile_id = ?", (profile_id,)) + txn.execute("DELETE FROM private_ind_bin WHERE profile_id = ?", (profile_id,)) return None d = self.dbpool.runInteraction(delete)