Skip to content

Commit

Permalink
Minor reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceCondor authored and nickjoanis committed Dec 4, 2024
1 parent fc80ba3 commit 229669c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions target_postgres/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ def _do_copy(

copy.write_row(processed_row)
def sanitize_null_text_characters(self, data):
"""Sanitizes null characters by replacing \u0000 with \uFFFD"""
"""Sanitizes null characters by replacing \u0000 with \ufffd"""

def replace_null_character(d):
return d.replace('\u0000', '\uFFFD')
return d.replace("\u0000", "\ufffd")

if isinstance(data, str):
data = replace_null_character(data)
Expand All @@ -211,7 +211,6 @@ def replace_null_character(d):

return data


def bulk_insert_records( # type: ignore[override]
self,
table: sa.Table,
Expand Down Expand Up @@ -255,7 +254,9 @@ def bulk_insert_records( # type: ignore[override]
}
for column in columns:
if self.connector.sanitize_null_text_characters:
insert_record[column.name] = self.sanitize_null_text_characters(record.get(column.name))
insert_record[column.name] = self.sanitize_null_text_characters(
record.get(column.name)
)
else:
insert_record[column.name] = record.get(column.name)
# No need to check for a KeyError here because the SDK already
Expand All @@ -275,7 +276,9 @@ def bulk_insert_records( # type: ignore[override]
}
for column in columns:
if self.connector.sanitize_null_text_characters:
insert_record[column.name] = self.sanitize_null_text_characters(record.get(column.name))
insert_record[column.name] = self.sanitize_null_text_characters(
record.get(column.name)
)
else:
insert_record[column.name] = record.get(column.name)
data.append(insert_record)
Expand Down

0 comments on commit 229669c

Please sign in to comment.