Skip to content

Commit

Permalink
Merge pull request #270 from JoshuaHuntley/dev/0.6.0
Browse files Browse the repository at this point in the history
Added quote_columns=(true | false) flag to the unique_combination_of_columns.sql macro
  • Loading branch information
Claire Carroll authored Sep 3, 2020
2 parents 7adb903 + f2aad3a commit 7d26745
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 16 additions & 2 deletions macros/schema_tests/unique_combination_of_columns.sql
Original file line number Diff line number Diff line change
@@ -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 (

Expand Down

0 comments on commit 7d26745

Please sign in to comment.