From dd4b47d8b1fee9d50a2b5a98f76a49428def8c47 Mon Sep 17 00:00:00 2001 From: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:26:35 -0700 Subject: [PATCH] Check length of escaped strings in the adapter test (#6567) * Check length of escaped strings in the adapter test * One column per line to improve readability --- .../Under the Hood-20230110-145648.yaml | 6 ++++ .../utils/fixture_escape_single_quotes.py | 33 ++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20230110-145648.yaml 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 """