From 225e329631be36066f123c07563daa1064a14a76 Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Fri, 25 Oct 2024 10:50:29 +0200 Subject: [PATCH] MNT: Added an error for comparison of multi-properties if the property is present several times only in the first argument --- src/linkahead/apiutils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index d70f937f..c2c687f1 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -342,8 +342,17 @@ def compare_entities(old_entity: Entity, # we have not yet compared properties that do not exist in old_entity for prop in new_entity.properties: - if len([0 for p in old_entity.properties if p.name.lower() == prop.name.lower()]) == 0: + # check how often the property appears in old_entity + num_old_prop = len([0 for p in old_entity.properties + if p.name.lower() == prop.name.lower()]) + if num_old_prop == 0: + # property is only present in new_entity - add to diff newdiff["properties"][prop.name] = {} + if num_old_prop > 1: + # Check whether the property is present multiple times in old_entity + # and raise error - result would be incorrect + raise NotImplementedError( + "Comparison not implemented for multi-properties.") # compare parents # ToDo: Compare using filter function, compare inheritance level for RTs -- GitLab