0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-20 19:14:04 +01:00

really fix queries to work with Postgres

(by going back to not using SQL directly)
This commit is contained in:
Hubert Chathi 2019-07-31 18:37:05 -04:00
parent 430ea08186
commit 73b26f827c

View file

@ -601,11 +601,11 @@ class DeviceStore(DeviceWorkerStore, BackgroundUpdateStore):
Returns: Returns:
defer.Deferred defer.Deferred
""" """
sql = """ yield self._simple_delete_one(
DELETE FROM devices table="devices",
WHERE user_id = ? AND device_id = ? AND hidden = ? keyvalues={"user_id": user_id, "device_id": device_id, "hidden": False},
""" desc="delete_device",
yield self._execute("delete_device", None, sql, user_id, device_id, False) )
self.device_id_exists_cache.invalidate((user_id, device_id)) self.device_id_exists_cache.invalidate((user_id, device_id))
@ -619,21 +619,13 @@ class DeviceStore(DeviceWorkerStore, BackgroundUpdateStore):
Returns: Returns:
defer.Deferred defer.Deferred
""" """
yield self._simple_delete_many(
if not device_ids or len(device_ids) == 0: table="devices",
return column="device_id",
sql = """ iterable=device_ids,
DELETE FROM devices keyvalues={"user_id": user_id, "hidden": False},
WHERE user_id = ? AND device_id IN (%s) AND hidden = ? desc="delete_devices",
""" % (
",".join("?" for _ in device_ids)
) )
values = [user_id]
values.extend(device_ids)
values.append(False)
yield self._execute("delete_devices", None, sql, *values)
for device_id in device_ids: for device_id in device_ids:
self.device_id_exists_cache.invalidate((user_id, device_id)) self.device_id_exists_cache.invalidate((user_id, device_id))