Actually encode dicts as json in the DB

This commit is contained in:
Erik Johnston 2014-08-14 14:30:25 +01:00
parent cbd5d55222
commit 6d6a1c3454
2 changed files with 4 additions and 3 deletions

View file

@ -81,11 +81,11 @@ class DataStore(RoomDataStore, RoomMemberStore, MessageStore, RoomStore,
"event_type", event.type,
"sender": event.user_id,
"room_id": event.room_id,
"content": event.content,
"content": json.dumps(event.content),
}
unrec = {k: v for k, v in event.get_full_dict() if k not in vals.keys()}
val["unrecognized_keys"] = unrec
val["unrecognized_keys"] = json.dumps(unrec)
yield self._simple_insert("events", vals)

View file

@ -288,7 +288,8 @@ class SQLBaseStore(object):
def _parse_event_from_row(self, row_dict):
d = copy.deepcopy({k: v for k, v in row.items() if v})
d.update(json.loads(row["unrecognized_keys"]))
d.update(json.loads(json.loads(row["unrecognized_keys"])))
d["content"] = json.loads(d["content"})
del d["unrecognized_keys"]
return self.event_factory.create_event(