From ebac8b3b4c844cbf2226c37179df4f1a7b9ed2b8 Mon Sep 17 00:00:00 2001 From: Bowrna Date: Fri, 2 Aug 2024 21:33:43 +0530 Subject: [PATCH] Fix broken campaign clone with deleted lists (#1966) Co-authored-by: Kailash Nadh --- queries.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/queries.sql b/queries.sql index 57cab4d4..bb730869 100644 --- a/queries.sql +++ b/queries.sql @@ -506,10 +506,12 @@ camp AS ( med AS ( INSERT INTO campaign_media (campaign_id, media_id, filename) (SELECT (SELECT id FROM camp), id, filename FROM media WHERE id=ANY($19::INT[])) +), +insLists AS ( + INSERT INTO campaign_lists (campaign_id, list_id, list_name) + SELECT (SELECT id FROM camp), id, name FROM lists WHERE id=ANY($14::INT[]) ) -INSERT INTO campaign_lists (campaign_id, list_id, list_name) - (SELECT (SELECT id FROM camp), id, name FROM lists WHERE id=ANY($14::INT[])) - RETURNING (SELECT id FROM camp); +SELECT id FROM camp; -- name: query-campaigns -- Here, 'lists' is returned as an aggregated JSON array from campaign_lists because