Skip to content

Commit a962aed

Browse files
author
Michael Brewer
committed
fix(event-sources): return for none for null types
1 parent 321f493 commit a962aed

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,13 @@ def ns_value(self) -> Optional[List[str]]:
106106
return self.get("NS")
107107

108108
@property
109-
def null_value(self) -> Optional[bool]:
109+
def null_value(self) -> None:
110110
"""An attribute of type Null.
111111
112112
Example:
113113
>>> {"NULL": True}
114114
"""
115-
item = self.get("NULL")
116-
return None if item is None else bool(item)
115+
return None
117116

118117
@property
119118
def s_value(self) -> Optional[str]:

tests/functional/test_data_classes.py

+10
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,19 @@ def test_dynamo_attribute_value_null_value():
544544
attribute_value = AttributeValue(example_attribute_value)
545545

546546
assert attribute_value.get_type == AttributeValueType.Null
547+
assert attribute_value.null_value is None
547548
assert attribute_value.null_value == attribute_value.get_value
548549

549550

551+
def test_dynamo_attribute_value_null_value_invalid():
552+
example_attribute_value = {"NULL": False}
553+
554+
attribute_value = AttributeValue(example_attribute_value)
555+
556+
assert attribute_value.get_type == AttributeValueType.Null
557+
assert attribute_value.null_value is None
558+
559+
550560
def test_dynamo_attribute_value_s_value():
551561
example_attribute_value = {"S": "Hello"}
552562

0 commit comments

Comments
 (0)