Open dappiu opened 6 years ago
It seems to me that it's not correct behavior, cause resource bound to invalid uri. You can get a null value with that patch:
--- schema.py.old 2019-08-19 15:12:04.712622200 +0400
+++ schema.py 2019-08-19 15:07:01.547122200 +0400
@@ -213,6 +213,8 @@
return all(((i.default is not None) or i.nullable for i in (self.fields or {}).values()))
def format(self, item):
+ if item is None:
+ return None
return OrderedDict((key, field.output(key, item)) for key, field in self.fields.items() if 'r' in field.io)
def convert(self, instance, update=False, pre_resolved_properties=None, patchable=False, strict=False):
Maybe not an issue and I'm just missing something. I'll try to explain me with some code
I have a situation like this:
Now, I'm expecting that when I fetch a user instance (GET /user/), if the instance has the id_user_status set to None (and consequently user_status relationship also returns None), the value of the key
user_status
to be None. Instead I get an object with every field of the user-status resource set to None (exception made for the $uri that is set to/user-status/None
)I tried passing
nullable=True
anddefault=None
toInline()
, but nothing changes.Is this the correct behaviour? Is there a way in which I can change this behaviour and simply get a null value as a representation for None?
Thanks