Skip to content

fix: Use tuples for pkey check #446

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

Merged
merged 3 commits into from
Sep 27, 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
6 changes: 3 additions & 3 deletions target_postgres/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ def bulk_insert_records( # type: ignore[override]
data_to_insert: list[dict[str, t.Any]] = []

if self.append_only is False:
insert_records: dict[str, dict] = {} # pk : record
insert_records: dict[tuple, dict] = {} # pk tuple: record
for record in records:
insert_record = {
column.name: record.get(column.name) for column in columns
}
# No need to check for a KeyError here because the SDK already
# guarantees that all key properties exist in the record.
primary_key_value = "".join([str(record[key]) for key in primary_keys])
insert_records[primary_key_value] = insert_record
primary_key_tuple = tuple(record[key] for key in primary_keys)
insert_records[primary_key_tuple] = insert_record
data_to_insert = list(insert_records.values())
else:
for record in records:
Expand Down