summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-03-04 16:35:08 +0000
committerMark Haines <mjark@negativecurvature.net>2016-03-04 16:35:08 +0000
commitb7a3be693b06b325d74060df6f809580e1225acd (patch)
tree6ccd3c898749e0ea98e820c586895b66cbc626b2 /synapse/storage/_base.py
parentMerge pull request #625 from matrix-org/erikj/kick_ban_sync (diff)
parentPrefill from the correct stream (diff)
downloadsynapse-b7a3be693b06b325d74060df6f809580e1225acd.tar.xz
Merge pull request #618 from matrix-org/markjh/pushrule_stream
Add a stream for push rule updates
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):