summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py4
-rw-r--r--synapse/storage/schema/im.sql2
2 files changed, 5 insertions, 1 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 7068424441..f8d895082d 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -39,6 +39,7 @@ from .state import StateStore
 from .signatures import SignatureStore
 
 from syutil.base64util import decode_base64
+from syutil.jsonutil import encode_canonical_json
 
 from synapse.crypto.event_signing import compute_event_reference_hash
 
@@ -162,7 +163,8 @@ class DataStore(RoomMemberStore, RoomStore,
             table="event_json",
             values={
                 "event_id": event.event_id,
-                "json": json.dumps(event_dict, separators=(',', ':')),
+                "room_id": event.room_id,
+                "json": encode_canonical_json(event_dict),
             },
             or_replace=True,
         )
diff --git a/synapse/storage/schema/im.sql b/synapse/storage/schema/im.sql
index cb0c494ddf..0300bb29e1 100644
--- a/synapse/storage/schema/im.sql
+++ b/synapse/storage/schema/im.sql
@@ -35,11 +35,13 @@ CREATE INDEX IF NOT EXISTS events_room_id ON events (room_id);
 
 CREATE TABLE IF NOT EXISTS event_json(
     event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     json BLOB NOT NULL,
     CONSTRAINT ev_j_uniq UNIQUE (event_id)
 );
 
 CREATE INDEX IF NOT EXISTS event_json_id ON event_json(event_id);
+CREATE INDEX IF NOT EXISTS event_json_room_id ON event_json(room_id);
 
 
 CREATE TABLE IF NOT EXISTS state_events(