[Feature] Escape the adapter-specific string literal delimiter within the string_literal
macro
#293
Labels
enhancement
New feature or request
string_literal
macro
#293
Originally posted by @nicods-fr in dbt-labs/dbt-core#10654 (comment) :
Describe the feature
Provide a cross-database Jinja macro that converts a Jinja string into a SQL string literal.
Example 1
This code:
should render this SQL in Postgres:
which would return this when executed:
Example 2
This code:
should render this SQL in Postgres:
which would return this when executed:
Describe alternatives you've considered
We could update the implementation of
string_literal
to useescape_single_quotes
, but it would change the behavior for anyone that is already using these long-standing macros in concert with each other (like here) or is otherwise usingstring_literal
with full knowledge of its current limitations. 💥We could also keep things as-is, one consequence being user-level overrides like described in dbt-labs/dbt-core#10654 (comment)
Anything else?
Put another way, we should provide a cross-database Jinja macro that safely does two things to a string value:
escape_single_quotes
macro)string_literal
macro)The
quote
config withinaccepted_values
should then use that implementation.The text was updated successfully, but these errors were encountered: