From 12762a3ab185b528c2b3ad7ea2d925513ac04a8d Mon Sep 17 00:00:00 2001 From: "R. Joshua Huntley" Date: Fri, 28 Aug 2020 09:53:19 -0700 Subject: [PATCH 1/2] Upgrading schema test unique_comination_of_columns.sql to allow quoting of columns. --- .../unique_combination_of_columns.sql | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/macros/schema_tests/unique_combination_of_columns.sql b/macros/schema_tests/unique_combination_of_columns.sql index b7326470..733f4e86 100644 --- a/macros/schema_tests/unique_combination_of_columns.sql +++ b/macros/schema_tests/unique_combination_of_columns.sql @@ -1,8 +1,22 @@ -{% macro test_unique_combination_of_columns(model) %} +{% macro test_unique_combination_of_columns(model, quote_columns = false) %} {%- set columns = kwargs.get('combination_of_columns', kwargs.get('arg')) %} -{%- set columns_csv=columns | join(', ') %} +{% if not quote_columns %} + {%- set column_list=columns %} +{% elif quote_columns %} + {%- set column_list=[] %} + {% for column in columns -%} + {% set column_list = column_list.append( adapter.quote(column) ) %} + {%- endfor %} +{% else %} + {{ exceptions.raise_compiler_error( + "`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '" ~ quote ~"'.'" + ) }} +{% endif %} + +{%- set columns_csv=column_list | join(', ') %} + with validation_errors as ( From f2aad3a2914e2f36224be33df360f196ff5449cd Mon Sep 17 00:00:00 2001 From: "R. Joshua Huntley" Date: Fri, 28 Aug 2020 10:10:40 -0700 Subject: [PATCH 2/2] Adding info to changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78cf5562..4cd14b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,3 +49,4 @@ database adapters that use different prefixes (#267) ## Quality of life * Improve release process, and fix tests (#251) * Make deprecation warnings more useful (#258 @tayloramurphy) +* Upgrade unique_combination_of_columns.sql macro to respect the quote_columns=TRUE flag as a test argument