Skip to content

Commit

Permalink
Use tuples for checking pk equality
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceCondor committed Sep 27, 2024
1 parent 5765f12 commit 1fe31b6
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 1fe31b6

Please sign in to comment.