summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2016-03-08 17:35:09 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2016-03-08 17:35:09 +0000
commit3b97797c8d60bf9b6e5e09396620144ee9a8bc83 (patch)
tree3f4d437943e53a3f4be2d6626f0585d471c0cb7f /synapse/storage/_base.py
parentIdempotent-ise schema update script (diff)
parentMerge pull request #630 from matrix-org/dbkr/post_urlencoded_encode_params (diff)
downloadsynapse-3b97797c8d60bf9b6e5e09396620144ee9a8bc83.tar.xz
Merge branch 'develop' into daniel/ick
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 2e97ac84a8..7dc67ecd57 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -770,18 +770,29 @@ class SQLBaseStore(object):
             table : string giving the table name
             keyvalues : dict of column names and values to select the row with
         """
+        return self.runInteraction(
+            desc, self._simple_delete_one_txn, table, keyvalues
+        )
+
+    @staticmethod
+    def _simple_delete_one_txn(txn, table, keyvalues):
+        """Executes a DELETE query on the named table, expecting to delete a
+        single row.
+
+        Args:
+            table : string giving the table name
+            keyvalues : dict of column names and values to select the row with
+        """
         sql = "DELETE FROM %s WHERE %s" % (
             table,
             " AND ".join("%s = ?" % (k, ) for k in keyvalues)
         )
 
-        def func(txn):
-            txn.execute(sql, keyvalues.values())
-            if txn.rowcount == 0:
-                raise StoreError(404, "No row found")
-            if txn.rowcount > 1:
-                raise StoreError(500, "more than one row matched")
-        return self.runInteraction(desc, func)
+        txn.execute(sql, keyvalues.values())
+        if txn.rowcount == 0:
+            raise StoreError(404, "No row found")
+        if txn.rowcount > 1:
+            raise StoreError(500, "more than one row matched")
 
     @staticmethod
     def _simple_delete_txn(txn, table, keyvalues):