PynamoDB
PynamoDB copied to clipboard
deserialize is not called for null values
I would like to handle null values when deserializing. I have the following custom attribute:
class TestAttribute(Attribute):
attr_type = BINARY
def serialize(self, value: Any) -> Any:
return json.dumps(value)
def deserialize(self, value: Any) -> Any:
raise RuntimeError("STOP!!")
being used in a model:
class MyModel(Model):
test_field = TestAttribute(null=True)
If the field has data in it, I get the runtime error STOP!!
as expected.
If the field is empty, there is no such error, and e.test_field
is None
.
How can I handle the behaviour when a value is null?