Skip to content
Snippets Groups Projects
Verified Commit 9191afa8 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: A bit more informative error message.

parent bf854629
No related branches found
No related tags found
2 merge requests!93Release 0.11.0,!81F merge conflict error
Pipeline #30772 passed
......@@ -46,8 +46,7 @@ from caosdb.exceptions import CaosDBException
class EntityMergeConflictError(CaosDBException):
"""An error that is raised in case of an unresolvable conflict when merging
to entities.
two entities.
"""
......@@ -372,13 +371,14 @@ def empty_diff(old_entity: Entity, new_entity: Entity, compare_referenced_record
return True
def merge_entities(entity_a: Entity, entity_b: Entity, merge_references_with_empty_diffs=True, force=False):
def merge_entities(entity_a: Entity, entity_b: Entity, merge_references_with_empty_diffs=True,
force=False):
"""Merge entity_b into entity_a such that they have the same parents and properties.
datatype, unit, value, name and description will only be changed in entity_a
if they are None for entity_a and set for entity_b. If there is a
corresponding value for entity_a different from None an
EntityMergeConflictError will be raised informing of an unresolvable merge
corresponding value for entity_a different from None, an
EntityMergeConflictError will be raised to inform about an unresolvable merge
conflict.
The merge operation is done in place.
......@@ -476,7 +476,8 @@ def merge_entities(entity_a: Entity, entity_b: Entity, merge_references_with_emp
setattr(entity_a, special_attribute, sa_b)
else:
raise EntityMergeConflictError(
f"Conflict in special attribute {special_attribute}.")
f"Conflict in special attribute {special_attribute}:\n"
f"A: {sa_a}\nB: {sa_b}")
return entity_a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment