Skip to content

Commit

Permalink
fixes setting native value None
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfix committed Mar 25, 2024
1 parent dba0114 commit f17abc9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions dlt/common/configuration/specs/base_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ def _apply_init_value(self, init_value: Any = None) -> None:
self.update(init_value)
elif init_value is not None:
self.parse_native_representation(init_value)
else:
return
if not self.is_partial():
self.resolve()

Expand Down
3 changes: 1 addition & 2 deletions dlt/destinations/impl/duckdb/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ def _conn_str(self) -> str:

def __init__(self, conn_or_path: Union[str, DuckDBPyConnection] = None) -> None:
"""Access to duckdb database at a given path or from duckdb connection"""
self.database = conn_or_path # type: ignore[assignment]
self.resolve()
self._apply_init_value(conn_or_path)


@configspec
Expand Down
18 changes: 11 additions & 7 deletions tests/load/duckdb/test_duckdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def test_duckdb_database_path() -> None:
# provide absolute path
db_path = os.path.abspath("_storage/abs_test_quack.duckdb")
c = resolve_configuration(
DuckDbClientConfiguration(credentials=f"duckdb:///{db_path}")
)._bind_dataset_name(
dataset_name="test_dataset",
DuckDbClientConfiguration(credentials=f"duckdb:///{db_path}")._bind_dataset_name(
dataset_name="test_dataset",
)
)
assert os.path.isabs(c.credentials.database)
assert c.credentials._conn_str().lower() == db_path.lower()
Expand All @@ -123,8 +123,10 @@ def test_duckdb_database_path() -> None:

# set just path as credentials
db_path = "_storage/path_test_quack.duckdb"
c = resolve_configuration(DuckDbClientConfiguration(credentials=db_path))._bind_dataset_name(
dataset_name="test_dataset"
c = resolve_configuration(
DuckDbClientConfiguration(credentials=db_path)._bind_dataset_name(
dataset_name="test_dataset"
)
)
assert c.credentials._conn_str().lower() == os.path.abspath(db_path).lower()
conn = c.credentials.borrow_conn(read_only=False)
Expand All @@ -133,8 +135,10 @@ def test_duckdb_database_path() -> None:
p = p.drop()

db_path = os.path.abspath("_storage/abs_path_test_quack.duckdb")
c = resolve_configuration(DuckDbClientConfiguration(credentials=db_path))._bind_dataset_name(
dataset_name="test_dataset"
c = resolve_configuration(
DuckDbClientConfiguration(credentials=db_path)._bind_dataset_name(
dataset_name="test_dataset"
)
)
assert os.path.isabs(c.credentials.database)
assert c.credentials._conn_str().lower() == db_path.lower()
Expand Down

0 comments on commit f17abc9

Please sign in to comment.