diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py index 18d20457044ecd7ee538bc4b5785d116a5403060..f3195b8e152f0cb13e5dab3e3a449b7bb36623b4 100644 --- a/src/caosdb/apiutils.py +++ b/src/caosdb/apiutils.py @@ -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