summary refs log tree commit diff
path: root/synapse/storage/engines/postgres.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-10 15:59:35 +0100
committerGitHub <noreply@github.com>2019-10-10 15:59:35 +0100
commit329eae9cda8c57b00ce5aeba5ac12356a8ae9775 (patch)
tree810580232ad1fbb8943dbb37870978d44b62ddbe /synapse/storage/engines/postgres.py
parentMerge pull request #6191 from matrix-org/rav/fix_packaging (diff)
parentFix postgres unit tests (diff)
downloadsynapse-329eae9cda8c57b00ce5aeba5ac12356a8ae9775.tar.xz
Merge pull request #6186 from matrix-org/erikj/disable_sql_bytes
Disable bytes usage with postgres
Diffstat (limited to 'synapse/storage/engines/postgres.py')
-rw-r--r--synapse/storage/engines/postgres.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/storage/engines/postgres.py b/synapse/storage/engines/postgres.py
index 601617b21e..d670286fa5 100644
--- a/synapse/storage/engines/postgres.py
+++ b/synapse/storage/engines/postgres.py
@@ -22,6 +22,13 @@ class PostgresEngine(object):
     def __init__(self, database_module, database_config):
         self.module = database_module
         self.module.extensions.register_type(self.module.extensions.UNICODE)
+
+        # Disables passing `bytes` to txn.execute, c.f. #6186. If you do
+        # actually want to use bytes than wrap it in `bytearray`.
+        def _disable_bytes_adapter(_):
+            raise Exception("Passing bytes to DB is disabled.")
+
+        self.module.extensions.register_adapter(bytes, _disable_bytes_adapter)
         self.synchronous_commit = database_config.get("synchronous_commit", True)
         self._version = None  # unknown as yet