feat(serialisation): allow null values
This commit is contained in:
@@ -252,6 +252,9 @@ class Base(_RegisteringBase):
|
||||
if t is None:
|
||||
return value
|
||||
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
if t.__module__ == "typing":
|
||||
origin = getattr(t, "__origin__")
|
||||
t = (
|
||||
|
||||
@@ -60,8 +60,13 @@ class BaseObjectSerializer:
|
||||
chunkable = False
|
||||
detach = False
|
||||
|
||||
# skip nulls or props marked to be ignored with "__" or "_"
|
||||
if value is None or prop.startswith(("__", "_")):
|
||||
# skip props marked to be ignored with "__" or "_"
|
||||
if prop.startswith(("__", "_")):
|
||||
continue
|
||||
|
||||
# allow serialisation of nulls
|
||||
if not value:
|
||||
object_builder[prop] = value
|
||||
continue
|
||||
|
||||
# don't prepopulate id as this will mess up hashing
|
||||
|
||||
Reference in New Issue
Block a user