From e50273cfe66fcfd0bbb8f811996923a32f872bb9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 18 Dec 2020 17:33:47 +0000 Subject: [PATCH] Update selectStateInRange to not return irrelevant events --- syncapi/storage/postgres/output_room_events_table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncapi/storage/postgres/output_room_events_table.go b/syncapi/storage/postgres/output_room_events_table.go index f4bbebd26..07d0b1fbc 100644 --- a/syncapi/storage/postgres/output_room_events_table.go +++ b/syncapi/storage/postgres/output_room_events_table.go @@ -106,7 +106,7 @@ const updateEventJSONSQL = "" + const selectStateInRangeSQL = "" + "SELECT id, headered_event_json, exclude_from_sync, add_state_ids, remove_state_ids" + " FROM syncapi_output_room_events" + - " WHERE (id > $1 AND id <= $2) AND (add_state_ids IS NOT NULL OR remove_state_ids IS NOT NULL)" + + " WHERE (id > $1 AND id <= $2) AND (cardinality (add_state_ids) > 0 OR cardinality (remove_state_ids) > 0)" + " AND ( $3::text[] IS NULL OR sender = ANY($3) )" + " AND ( $4::text[] IS NULL OR NOT(sender = ANY($4)) )" + " AND ( $5::text[] IS NULL OR type LIKE ANY($5) )" +