From f19c59db2339bcaa6e8f035596eb8c093d9e0e78 Mon Sep 17 00:00:00 2001 From: Igor Kotrasinski Date: Mon, 25 Jun 2018 18:48:29 +0200 Subject: [PATCH] Fix setting to-one relationship value to None Signed-off-by: Igor Kotrasinski --- src/jsonapi_client/relationships.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/jsonapi_client/relationships.py b/src/jsonapi_client/relationships.py index 2f2c6b1..ad439d7 100644 --- a/src/jsonapi_client/relationships.py +++ b/src/jsonapi_client/relationships.py @@ -271,6 +271,12 @@ def as_json_resource_identifiers(self) -> dict: return None return self._resource_identifier.as_resource_identifier_dict() + def _value_to_identifier(self, value: R_IDENT_TYPES, type_: str='') \ + -> 'Union[ResourceIdentifier, ResourceObject]': + if value is None: + return None + return super()._value_to_identifier(value, type_) + def set(self, new_value: R_IDENT_TYPES, type_: str='') -> None: self._resource_identifier = self._value_to_identifier(new_value, type_)