Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added quote_columns=(true | false) flag to the unique_combination_of_columns.sql macro #270

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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