summary refs log tree commit diff
path: root/synapse/storage/engines
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-10 13:41:54 +0100
committerErik Johnston <erik@matrix.org>2015-04-10 13:41:54 +0100
commit7ed2ec3061b12ad79f3bd07da8758c5e41af8e5e (patch)
tree2172b59fd044f027b6c7b2fa031fd3c04e1219c7 /synapse/storage/engines
parentBump schema version (diff)
downloadsynapse-7ed2ec3061b12ad79f3bd07da8758c5e41af8e5e.tar.xz
Handle the fact that in sqlite binary data might be stored as unicode or bytes
Diffstat (limited to 'synapse/storage/engines')
-rw-r--r--synapse/storage/engines/maria.py5
-rw-r--r--synapse/storage/engines/sqlite3.py7
2 files changed, 11 insertions, 1 deletions
diff --git a/synapse/storage/engines/maria.py b/synapse/storage/engines/maria.py
index 230b32858c..c934376930 100644
--- a/synapse/storage/engines/maria.py
+++ b/synapse/storage/engines/maria.py
@@ -27,7 +27,7 @@ class MariaEngine(object):
 
     def encode_parameter(self, param):
         if isinstance(param, types.BufferType):
-            return str(param)
+            return bytes(param)
         return param
 
     def on_new_connection(self, db_conn):
@@ -45,3 +45,6 @@ class MariaEngine(object):
         if isinstance(error, self.module.DatabaseError):
             return error.sqlstate == "40001" and error.errno == 1213
         return False
+
+    def load_unicode(self, v):
+        return bytes(v).decode("UTF8")
diff --git a/synapse/storage/engines/sqlite3.py b/synapse/storage/engines/sqlite3.py
index 72c11df461..389df35eb5 100644
--- a/synapse/storage/engines/sqlite3.py
+++ b/synapse/storage/engines/sqlite3.py
@@ -15,6 +15,8 @@
 
 from synapse.storage import prepare_database, prepare_sqlite3_database
 
+import types
+
 
 class Sqlite3Engine(object):
     def __init__(self, database_module):
@@ -35,3 +37,8 @@ class Sqlite3Engine(object):
 
     def is_deadlock(self, error):
         return False
+
+    def load_unicode(self, v):
+        if isinstance(v, types.UnicodeType):
+            return v
+        return bytes(v).decode("UTF8")