diff --git a/.changes/unreleased/Under the Hood-20230110-145648.yaml b/.changes/unreleased/Under the Hood-20230110-145648.yaml new file mode 100644 index 00000000000..9a21f1da645 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230110-145648.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Check length of escaped strings in the adapter test +time: 2023-01-10T14:56:48.044198-07:00 +custom: + Author: dbeatty10 + Issue: "6566" diff --git a/tests/adapter/dbt/tests/adapter/utils/fixture_escape_single_quotes.py b/tests/adapter/dbt/tests/adapter/utils/fixture_escape_single_quotes.py index d7e7148b886..aeaaaa44193 100644 --- a/tests/adapter/dbt/tests/adapter/utils/fixture_escape_single_quotes.py +++ b/tests/adapter/dbt/tests/adapter/utils/fixture_escape_single_quotes.py @@ -1,15 +1,37 @@ # escape_single_quotes models__test_escape_single_quotes_quote_sql = """ -select '{{ escape_single_quotes("they're") }}' as actual, 'they''re' as expected union all -select '{{ escape_single_quotes("they are") }}' as actual, 'they are' as expected +select + '{{ escape_single_quotes("they're") }}' as actual, + 'they''re' as expected, + {{ length(string_literal(escape_single_quotes("they're"))) }} as actual_length, + 7 as expected_length + +union all + +select + '{{ escape_single_quotes("they are") }}' as actual, + 'they are' as expected, + {{ length(string_literal(escape_single_quotes("they are"))) }} as actual_length, + 8 as expected_length """ # The expected literal is 'they\'re'. The second backslash is to escape it from Python. models__test_escape_single_quotes_backslash_sql = """ -select '{{ escape_single_quotes("they're") }}' as actual, 'they\\'re' as expected union all -select '{{ escape_single_quotes("they are") }}' as actual, 'they are' as expected +select + '{{ escape_single_quotes("they're") }}' as actual, + 'they\\'re' as expected, + {{ length(string_literal(escape_single_quotes("they're"))) }} as actual_length, + 7 as expected_length + +union all + +select + '{{ escape_single_quotes("they are") }}' as actual, + 'they are' as expected, + {{ length(string_literal(escape_single_quotes("they are"))) }} as actual_length, + 8 as expected_length """ @@ -21,4 +43,7 @@ - assert_equal: actual: actual expected: expected + - assert_equal: + actual: actual_length + expected: expected_length """