From aaf5080a2733c925d9c9f4a80417251453773906 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 19 Mar 2023 12:53:05 +0530 Subject: [PATCH] Fix discrepency in SQL query/export queries. Closes #1241. --- queries.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queries.sql b/queries.sql index 4cd18d5..731e4cf 100644 --- a/queries.sql +++ b/queries.sql @@ -323,13 +323,13 @@ SELECT subscribers.id, subscribers.created_at, subscribers.updated_at FROM subscribers - LEFT JOIN subscriber_lists sl + LEFT JOIN subscriber_lists ON ( -- Optional list filtering. (CASE WHEN CARDINALITY($1::INT[]) > 0 THEN true ELSE false END) - AND sl.subscriber_id = subscribers.id + AND subscriber_lists.subscriber_id = subscribers.id ) - WHERE sl.list_id = ALL($1::INT[]) AND id > $2 + WHERE subscriber_lists.list_id = ALL($1::INT[]) AND id > $2 AND (CASE WHEN CARDINALITY($3::INT[]) > 0 THEN id=ANY($3) ELSE true END) %query% ORDER BY subscribers.id ASC LIMIT (CASE WHEN $4 < 1 THEN NULL ELSE $4 END);