diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2019-07-31 18:37:05 -0400 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2019-07-31 18:37:05 -0400 |
commit | 73b26f827ccb96a10629ecb0737bd3db4915bb14 (patch) | |
tree | c99c8d5801284849a8dffe6b462408d5fc4ab829 | |
parent | PostgreSQL, Y U no like? (diff) | |
download | synapse-73b26f827ccb96a10629ecb0737bd3db4915bb14.tar.xz |
really fix queries to work with Postgres
(by going back to not using SQL directly)
-rw-r--r-- | synapse/storage/devices.py | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index a1f12df907..9f2bb40834 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -601,11 +601,11 @@ class DeviceStore(DeviceWorkerStore, BackgroundUpdateStore): Returns: defer.Deferred """ - sql = """ - DELETE FROM devices - WHERE user_id = ? AND device_id = ? AND hidden = ? - """ - yield self._execute("delete_device", None, sql, user_id, device_id, False) + yield self._simple_delete_one( + table="devices", + keyvalues={"user_id": user_id, "device_id": device_id, "hidden": False}, + desc="delete_device", + ) self.device_id_exists_cache.invalidate((user_id, device_id)) @@ -619,21 +619,13 @@ class DeviceStore(DeviceWorkerStore, BackgroundUpdateStore): Returns: defer.Deferred """ - - if not device_ids or len(device_ids) == 0: - return - sql = """ - DELETE FROM devices - WHERE user_id = ? AND device_id IN (%s) AND hidden = ? - """ % ( - ",".join("?" for _ in device_ids) + yield self._simple_delete_many( + table="devices", + column="device_id", + iterable=device_ids, + keyvalues={"user_id": user_id, "hidden": False}, + desc="delete_devices", ) - values = [user_id] - values.extend(device_ids) - values.append(False) - - yield self._execute("delete_devices", None, sql, *values) - for device_id in device_ids: self.device_id_exists_cache.invalidate((user_id, device_id)) |