Skip to content

Commit

Permalink
Check length of escaped strings in the adapter test (#6567)
Browse files Browse the repository at this point in the history
* Check length of escaped strings in the adapter test

* One column per line to improve readability
  • Loading branch information
dbeatty10 authored Jan 11, 2023
1 parent eb200b4 commit dd4b47d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230110-145648.yaml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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
"""


Expand All @@ -21,4 +43,7 @@
- assert_equal:
actual: actual
expected: expected
- assert_equal:
actual: actual_length
expected: expected_length
"""

0 comments on commit dd4b47d

Please sign in to comment.