diff --git a/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql b/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql index 385fd73f..882eebdb 100644 --- a/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql +++ b/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql @@ -77,15 +77,15 @@ union all {%- set column_type = column_name_to_data_types[column_name] %} - {#-- wrap yaml strings in quotes, apply cast --#} + {#-- sanitize column_value: wrap yaml strings in quotes, apply cast --#} + {%- set column_value_clean = column_value -%} {%- if column_value is string -%} - {%- set row_update = {column_name: safe_cast(dbt.string_literal(dbt.escape_single_quotes(column_value)), column_type) } -%} + {%- set column_value_clean = dbt.string_literal(dbt.escape_single_quotes(column_value)) -%} {%- elif column_value is none -%} - {%- set row_update = {column_name: safe_cast('null', column_type) } -%} - {%- else -%} - {%- set row_update = {column_name: safe_cast(column_value, column_type) } -%} + {%- set column_value_clean = 'null' } -%} {%- endif -%} + {%- set row_update = {column_name: safe_cast(column_value_clean, column_type) } -%} {%- do formatted_row.update(row_update) -%} {%- endfor -%} {{ return(formatted_row) }} diff --git a/dbt/tests/adapter/unit_testing/test_case_insensitivity.py b/dbt/tests/adapter/unit_testing/test_case_insensitivity.py index 84a87c5c..f6f89766 100644 --- a/dbt/tests/adapter/unit_testing/test_case_insensitivity.py +++ b/dbt/tests/adapter/unit_testing/test_case_insensitivity.py @@ -1,6 +1,5 @@ import pytest from dbt.tests.util import run_dbt -from dbt.tests.fixtures.project import * my_model_sql = """ diff --git a/dbt/tests/adapter/unit_testing/test_invalid_input.py b/dbt/tests/adapter/unit_testing/test_invalid_input.py index a4d5aa6e..6c41ceb9 100644 --- a/dbt/tests/adapter/unit_testing/test_invalid_input.py +++ b/dbt/tests/adapter/unit_testing/test_invalid_input.py @@ -1,6 +1,5 @@ import pytest from dbt.tests.util import run_dbt, run_dbt_and_capture -from dbt.tests.fixtures.project import * my_model_sql = """ diff --git a/dbt/tests/adapter/unit_testing/test_types.py b/dbt/tests/adapter/unit_testing/test_types.py index 5dc9838c..1d19aafb 100644 --- a/dbt/tests/adapter/unit_testing/test_types.py +++ b/dbt/tests/adapter/unit_testing/test_types.py @@ -1,7 +1,6 @@ import pytest from dbt.tests.util import write_file, run_dbt -from dbt.tests.fixtures.project import * my_model_sql = """ select