Skip to content
Snippets Groups Projects

New f fix merge

Merged Florian Spreckelsen requested to merge f-fix-merge into dev
1 file
+ 43
43
Compare changes
  • Side-by-side
  • Inline
+ 43
43
@@ -170,6 +170,48 @@ def _resolve_datatype(prop: db.Property, remote_entity: db.Entity):
return prop
def _treat_merge_error_of(newrecord, record):
"""
The parameters are two entities that cannot be merged with the merge_entities function.
# This function checks for two obvious cases where no merge will ever be possible:
# 1. Two Entities with differing IDs
# 2. Two non-Entity values which differ
It creates a more informative logger message and raises an Exception in those cases.
"""
for this_p in newrecord.properties:
that_p = record.get_property(this_p.name)
if (isinstance(this_p.value, db.Entity)
and isinstance(that_p.value, db.Entity)):
if this_p.value.id is not None and that_p.value.id is not None:
if this_p.value.id != that_p.value.id:
logger.error("The Crawler is trying to merge two entities "
"because they should be the same object (same"
" identifiables), but they reference "
"different Entities with the same Property."
f"Problematic Property: {this_p.name}\n"
f"Referenced Entities: {this_p.value.id} and "
f"{that_p.value.id}\n"
f"{record}\n{newrecord}")
raise RuntimeError("Cannot merge Entities")
elif (not isinstance(this_p.value, db.Entity)
and not isinstance(that_p.value, db.Entity)):
if ((this_p.value != that_p.value)
# TODO can we also compare lists?
and not isinstance(this_p.value, list)
and not isinstance(that_p.value, list)):
logger.error("The Crawler is trying to merge two entities "
"because they should be the same object (same"
" identifiables), but they have "
"different values for the same Property."
f"Problematic Property: {this_p.name}\n"
f"Values: {this_p.value} and "
f"{that_p.value}\n"
f"{record}\n{newrecord}")
raise RuntimeError("Cannot merge Entities")
class SecurityMode(Enum):
RETRIEVE = 0
INSERT = 1
@@ -537,48 +579,6 @@ class Crawler(object):
return references
@staticmethod
def _treat_merge_error_of(newrecord, record):
"""
The parameters are two entities that cannot be merged with the merge_entities function.
# This function checks for two obvious cases where no merge will ever be possible:
# 1. Two Entities with differing IDs
# 2. Two non-Entity values which differ
It creates a more informative logger message and raises an Exception in those cases.
"""
for this_p in newrecord.properties:
that_p = record.get_property(this_p.name)
if (isinstance(this_p.value, db.Entity)
and isinstance(that_p.value, db.Entity)):
if this_p.value.id is not None and that_p.value.id is not None:
if this_p.value.id != that_p.value.id:
logger.error("The Crawler is trying to merge two entities "
"because they should be the same object (same"
" identifiables), but they reference "
"different Entities with the same Property."
f"Problematic Property: {this_p.name}\n"
f"Referenced Entities: {this_p.value.id} and "
f"{that_p.value.id}\n"
f"{record}\n{newrecord}")
raise RuntimeError("Cannot merge Entities")
elif (not isinstance(this_p.value, db.Entity)
and not isinstance(that_p.value, db.Entity)):
if ((this_p.value != that_p.value)
# TODO can we also compare lists?
and not isinstance(this_p.value, list)
and not isinstance(that_p.value, list)):
logger.error("The Crawler is trying to merge two entities "
"because they should be the same object (same"
" identifiables), but they have "
"different values for the same Property."
f"Problematic Property: {this_p.name}\n"
f"Values: {this_p.value} and "
f"{that_p.value}\n"
f"{record}\n{newrecord}")
raise RuntimeError("Cannot merge Entities")
def split_into_inserts_and_updates(self, ent_list: list[db.Entity]):
to_be_inserted: list[db.Entity] = []
to_be_updated: list[db.Entity] = []
@@ -703,7 +703,7 @@ class Crawler(object):
record,
referencing_entities=referencing_entities)
newrecord = self.get_from_any_cache(identifiable)
merge_entities(newrecord, record)
merge_entities(newrecord, record, merge_id_with_resolved_entity=True)
if len(flat) > 0:
circle = self.detect_circular_dependency(flat)
if circle is None:
Loading