Skip to content

Commit

Permalink
ensure defaults are set during deserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinner-lyft committed Sep 10, 2020
1 parent 93d4c28 commit 6a1b9e0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pynamodb/attributes.py
Expand Up @@ -317,10 +317,13 @@ def _deserialize(self, attribute_values: Dict[str, Dict[str, Any]]) -> None:
"""
Sets attributes sent back from DynamoDB on this object
"""
self.attribute_values = {}
self._set_defaults(_user_instantiated=False)
for name, attr in self.get_attributes().items():
attribute_value = attribute_values.get(attr.attr_name, {NULL: True})
value = None if NULL in attribute_value else attr.deserialize(attr.get_value(attribute_value))
setattr(self, name, value)
attribute_value = attribute_values.get(attr.attr_name)
if attribute_value and NULL not in attribute_value:
value = attr.deserialize(attr.get_value(attribute_value)
setattr(self, name, value)

def __eq__(self, other: Any) -> bool:
# This is required so that MapAttribute can call this method.
Expand Down

0 comments on commit 6a1b9e0

Please sign in to comment.