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

Use quotes for database and schema name #33

Merged
merged 2 commits into from
Feb 1, 2024
Merged
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
8 changes: 4 additions & 4 deletions target_duckdb/db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ def table_name(self, stream_name, is_temporary=False, without_schema=False):
if without_schema:
return f'"{pg_table_name.lower()}"'
elif self.catalog_name:
return f'{self.catalog_name}.{self.schema_name}."{pg_table_name.lower()}"'
return f'"{self.catalog_name}"."{self.schema_name}"."{pg_table_name.lower()}"'
else:
return f'{self.schema_name}."{pg_table_name.lower()}"'
return f'"{self.schema_name}"."{pg_table_name.lower()}"'

def record_primary_key_string(self, record):
if len(self.stream_schema_message["key_properties"]) == 0:
Expand Down Expand Up @@ -530,9 +530,9 @@ def create_schema_if_not_exists(self, table_columns_cache=None):

if len(schema_rows) == 0:
if catalog_name:
query = f"CREATE SCHEMA IF NOT EXISTS {catalog_name}.{schema_name}"
query = f'CREATE SCHEMA IF NOT EXISTS "{catalog_name}"."{schema_name}"'
else:
query = f"CREATE SCHEMA IF NOT EXISTS {schema_name}"
query = f'CREATE SCHEMA IF NOT EXISTS "{schema_name}"'

self.logger.info(
"Schema '%s' does not exist. Creating... %s", schema_name, query
Expand Down
Loading