From 5c0693b175a6cdd0697c6810dec50730219df28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Tue, 5 Aug 2014 10:53:40 +0100 Subject: [PATCH] Further refactored SQLiteAdapter calling the super method instead of duplicating the code --- gluon/dal.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/gluon/dal.py b/gluon/dal.py index f1eb604d..3a4fcee4 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -2439,24 +2439,19 @@ class SQLiteAdapter(BaseAdapter): self.expand(second, 'string')) def delete(self, tablename, query): - sql = self._delete(tablename, query) - ### Special code to Handle CASCADE in SQLite & SpatiaLite + # SQLite requires its own delete to handle CASCADE db = self.db table = db[tablename] deleted = [x[table._id.name] for x in db(query).select(table._id)] - ### end special code to handle CASCADE in SQLite & SpatiaLite - self.execute(sql) - try: - counter = self.cursor.rowcount - except: - counter = None - ### special code to handle CASCADE in SQLite & SpatiaLite + + counter = super(SQLiteAdapter, self).delete(tablename, query) + if counter: for field in table._referenced_by: if field.type == 'reference '+ tablename \ and field.ondelete == 'CASCADE': db(field.belongs(deleted)).delete() - ### end special code to handle CASCADE in SQLite & SpatiaLite + return counter def select(self, query, fields, attributes):