We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
STOP!!
If the field is empty, there is no such error, and e.test_field is None.
e.test_field
None
How can I handle the behaviour when a value is null?
The text was updated successfully, but these errors were encountered:
Unfortunately this check simply won't let you have that:
PynamoDB/pynamodb/attributes.py
Lines 431 to 432 in 4b86304
(Curiously, the NULL DynamoDB attribute value would also have the same effect, making it indistinguishable from absence of value. A shame.)
NULL
Typically I'd override a model's deserialize if I want the opportunity to work with the raw data before field-by-field deserialization.
deserialize
Sorry, something went wrong.
No branches or pull requests
I would like to handle null values when deserializing. I have the following custom attribute:
being used in a model:
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
isNone
.How can I handle the behaviour when a value is null?
The text was updated successfully, but these errors were encountered: