summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2016-10-14 16:20:24 +0100
committerDavid Baker <dave@matrix.org>2016-10-14 16:20:24 +0100
commit29c592202136a3bdb04f78a49d02b7b53893a973 (patch)
tree859cb1fb48fc164f4196409d31356f0f00f5cd4a
parentMerge remote-tracking branch 'origin/develop' into dbkr/password_reset_case_i... (diff)
downloadsynapse-29c592202136a3bdb04f78a49d02b7b53893a973.tar.xz
Revert part of 6207399
older sqlite doesn't support indexes on expressions, lets just
store things lowercase in the db
-rw-r--r--synapse/storage/registration.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index a6aa64f9fb..e404fa72de 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -458,27 +458,17 @@ class RegistrationStore(background_updates.BackgroundUpdateStore):
 
     @defer.inlineCallbacks
     def get_user_id_by_threepid(self, medium, address):
-        def f(txn):
-            sql = (
-                "SELECT user_id"
-                " FROM user_threepids"
-                " WHERE medium = ? AND LOWER(address) = LOWER(?)"
-            )
-            txn.execute(sql, (medium, address))
-            row = txn.fetchone()
-            if not row:
-                return None
-            if txn.rowcount > 1:
-                raise StoreError(500, "More than one row matched")
-            return {
-                "user_id": row[0]
-            }
-
-        res = yield self.runInteraction(
-            "get_user_id_by_threepid", f
+        ret = yield self._simple_select_one(
+            "user_threepids",
+            {
+                "medium": medium,
+                "address": address
+            },
+            ['user_id'], True, 'get_user_id_by_threepid'
         )
-
-        defer.returnValue(res)
+        if ret:
+            defer.returnValue(ret['user_id'])
+        defer.returnValue(None)
 
     def user_delete_threepids(self, user_id):
         return self._simple_delete(