Skip to content

Commit 1e74e87

Browse files
committed
Fix bug: checking if an object exists was resetting any properties that had been set to None locally.
1 parent 1abdbeb commit 1e74e87

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

fairgraph/kgobject.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,21 @@ def count(
497497
return response.total
498498

499499
def _update_empty_properties(self, data: JSONdict):
500-
"""Replace any empty properties (value None) with the supplied data"""
500+
"""
501+
Replace any empty properties (value None) with the supplied data
502+
unless the property was deliberately set to None.
503+
"""
501504
cls = self.__class__
505+
locally_modified = self.modified_data()
502506
deserialized_data = cls._deserialize_data(data, include_id=True)
503507
for prop in cls.all_properties:
504-
current_value = getattr(self, prop.name, None)
505-
if current_value is None:
506-
value = deserialized_data[prop.name]
507-
if value is not None:
508-
setattr(self, prop.name, value)
508+
expanded_path = expand_uri(prop.path, cls.context)
509+
if expanded_path not in locally_modified:
510+
current_value = getattr(self, prop.name, None)
511+
if current_value is None:
512+
value = deserialized_data.get(prop.name, None)
513+
if value is not None:
514+
setattr(self, prop.name, value)
509515
assert self.remote_data is not None
510516
for key, value in data.items():
511517
if not (key.startswith("Q") or key == "@context"):

0 commit comments

Comments
 (0)