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 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 (