Skip to content
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

fix(secrets): value should be enclosed in quotes #421

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt/adapters/duckdb/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def to_sql(self) -> str:
params.update(params.pop("secret_kwargs", {}))
params_sql = f",\n{tab}".join(
[
f"{key} {value}"
f"{key} '{value}'" if key not in ["type", "provider"] else f"{key} {value}"
for key, value in params.items()
if value is not None and key not in ["name", "persistent"]
]
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test_add_secret_with_empty_name():
assert sql == \
"""CREATE SECRET (
type s3,
key_id abc,
secret xyz,
region us-west-2
key_id 'abc',
secret 'xyz',
region 'us-west-2'
)"""


Expand Down Expand Up @@ -68,10 +68,10 @@ def test_add_secret_with_name():
assert sql == \
"""CREATE OR REPLACE SECRET my_secret (
type s3,
scope s3://my-bucket,
key_id abc,
secret xyz,
region us-west-2
scope 's3://my-bucket',
key_id 'abc',
secret 'xyz',
region 'us-west-2'
)"""


Expand Down Expand Up @@ -107,7 +107,7 @@ def test_add_unsupported_secret_param():
assert sql == \
"""CREATE OR REPLACE SECRET _dbt_secret_1 (
type s3,
password secret
password 'secret'
)"""
with pytest.raises(duckdb.BinderException) as e:
duckdb.sql(sql)
Expand Down Expand Up @@ -141,10 +141,10 @@ def test_add_azure_secret():
"""CREATE SECRET (
type azure,
provider service_principal,
tenant_id abc,
client_id xyz,
client_certificate_path foo\\bar\\baz.pem,
account_name 123
tenant_id 'abc',
client_id 'xyz',
client_certificate_path 'foo\\bar\\baz.pem',
account_name '123'
)"""


Expand All @@ -166,7 +166,7 @@ def test_add_hf_secret():
assert sql == \
"""CREATE SECRET (
type huggingface,
token abc
token 'abc'
)"""


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_duckdb_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_create_secret(self, connector):
connection.handle._cursor._cursor.execute.assert_called_with(
"""CREATE OR REPLACE SECRET _dbt_secret_1 (
type s3,
key_id abc,
secret xyz,
region us-west-2
key_id 'abc',
secret 'xyz',
region 'us-west-2'
)""")
Loading