-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Escape "
within adapter.quote
#105
Comments
@smilingthax Thank you for opening this issue along with #106 ! Please share more about what you are trying to do in these situations. The more detail the better 🙏 Also: Are you using dbt-postgres, or is it another database adapter that you are using? It sounds like you are primarily trying to use This looks like a feature request to me, so I'm going to switch the categorization for now. We can switch it back to a bug later as-needed. |
"
within adapter.quote
"
within adapter.quote
"
within adapter.quote
I'm currently using dbt-postgres (might change in the future). #106 is somewhat related (quote/escape), but deals with values, not table/column/... names. Generally, I'm working on some macros (for example: to handle migrations to change database-objects not currently tracked/supported by dbt), which should be "safe" to use. Contrary to my expectation from other sql libraries (e.g. node-postgres: IMHO I don't think this is the right choice. The default behaviour should be safe (yes, parameters, or sql, used with dbt do not usually come from totally 'untrusted' users, the possibility of sql-level injections is still quite undesired). |
It sounds like you'd like the following (correct me if I'm wrong):
ExampleE.g., you'd like to be able to do the following:
{%- set unquoted_identifier = 'foo"bar' -%}
{%- set quoted_identifier = adapter.quote(unquoted_identifier) -%}
select 1 as {{ quoted_identifier }} And have each of these commands give the following output: $ dbt compile -s my_model
18:51:42 Compiled node 'my_model' is:
select 1 as "foo""bar" $ dbt show -s my_model
18:50:34 Previewing node 'my_model':
| foo"bar |
| ------- |
| 1 | Additional contextLong term, we're interested in revisiting our implementations related quoting and the user interfaces (dbt-labs/dbt-core#2986). In the meantime, we've got a lot of different quoting-related things we'd like to document more thoroughly (dbt-labs/docs.getdbt.com#3518) |
Well, despite the name And wrt. to #106, I think
Yes. |
Is this a new bug?
Current Behavior
gives
"foo"bar"
.Expected Behavior
It should return
"foo""bar"
(Postgres, ... other DBs might differ?Steps To Reproduce
E.g. via dbt_project.yaml:
Relevant log output
No response
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: