diff --git a/dev-utils/watch_ddb_stream.py b/dev-utils/watch_ddb_stream.py index 6ee17d2..0abbdd1 100755 --- a/dev-utils/watch_ddb_stream.py +++ b/dev-utils/watch_ddb_stream.py @@ -14,8 +14,8 @@ DYNAMODB_STREAMS = make_dynamodb_stream_images_multicast() -def make_accept_stream_images(item_slicer: Callable[[ItemImages], str]): - def accept_stream_item(images: ItemImages): +def make_accept_stream_images(item_slicer: Callable[[ItemImages], dict]): + def accept_stream_item(images: ItemImages) -> None: old, new = images if not old: print(f"New item: {item_slicer(images)}") # type: ignore @@ -34,7 +34,7 @@ def make_key_slicer(table): except ValueError: range_key = "" - def extract_primary_key(images: ItemImages): + def extract_primary_key(images: ItemImages) -> dict: old, new = images item = new or old assert item is not None @@ -48,7 +48,7 @@ def extract_primary_key(images: ItemImages): def make_item_slicer(key_slicer, attribute_names): - def item_slicer(images: ItemImages): + def item_slicer(images: ItemImages) -> dict: old, new = images if not new: new = dict() diff --git a/xoto3/dynamodb/write_versioned/specify.py b/xoto3/dynamodb/write_versioned/specify.py index ea97ea0..2345498 100644 --- a/xoto3/dynamodb/write_versioned/specify.py +++ b/xoto3/dynamodb/write_versioned/specify.py @@ -61,16 +61,13 @@ def presume( ) hkey = hashable_key(item_key) if hkey not in table_data.items: + item_value = dynamodb_prewrite(item_value, prewrite_transform) if item_value else None + # this prewrite makes sure the value looks like it could have come out of DynamoDB. return VersionedTransaction( tables={ **transaction.tables, table_name: _TableData( - items={ - **table_data.items, - hkey: dynamodb_prewrite(item_value, prewrite_transform) - if item_value - else item_value, - }, + items={**table_data.items, hkey: item_value}, effects=table_data.effects, key_attributes=table_data.key_attributes, ),