From 6da308bf53e01c95220bf5077b58c4ffe6234f9f Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 23 May 2024 11:53:14 -0400 Subject: [PATCH] support for unique where clauses for each relation passed to union_relations currently when a where clause is passed to union_relations, it is used for every relation that was passed. In some situations, this approach is not ideal. The proposed code change here maintains current functionality of passing strings to the where param but also allows for lists to be passed just like how the relations are passed to the relations parameter. Support for specific where clauses for each relation allows for more flexibility in the way the macro can be deployed --- macros/sql/union.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macros/sql/union.sql b/macros/sql/union.sql index ac289e2f..354ce49b 100644 --- a/macros/sql/union.sql +++ b/macros/sql/union.sql @@ -115,7 +115,11 @@ from {{ relation }} {% if where -%} - where {{ where }} + {% if where is string -%} + where {{ where }} + {% else %} + where {{ where[loop.index0] }} + {%- endif %} {%- endif %} )