feat(serialisation): allow null values

This commit is contained in:
izzy lyseggen
2021-12-16 16:41:09 +00:00
parent af50afe3ff
commit ca472716db
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -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