Skip to content

Commit

Permalink
Prevent errors when field truncation is configured for a nullable str…
Browse files Browse the repository at this point in the history
…ing field
  • Loading branch information
woodlee committed Nov 11, 2021
1 parent 602c174 commit 1de9836
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cdc_kafka/tracked_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def __init__(self, name: str, sql_type_name: str, change_table_ordinal: int, pri
f'string field (SQL type is {sql_type_name}).')
orig_transform = self.transform_fn
if orig_transform is not None:
self.transform_fn = lambda x: orig_transform(x)[:int(truncate_after)]
# TODO: this prevents orig_transform from ever receiving a None argument; is that okay??
self.transform_fn = lambda x: orig_transform(x)[:int(truncate_after)] if x is not None else x
else:
self.transform_fn = lambda x: x[:int(truncate_after)]
self.transform_fn = lambda x: x[:int(truncate_after)] if x is not None else x


class TrackedTable(object):
Expand Down

0 comments on commit 1de9836

Please sign in to comment.