From 900cb2ba859855f21c483cdb1b0a0cbd630ec2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 30 Oct 2024 11:10:20 +0100 Subject: [PATCH 1/3] FIX: do not use other list if list comparison says lists are equal --- CHANGELOG.md | 2 ++ src/linkahead/apiutils.py | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f2498a..92ecc008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - convenience functions `value_matches_versionid`, `get_id_from_versionid` and `get_versionid` ### Changed ### +- `compare_entities` is now case insensitive with respect to property and + recordtype names ### Deprecated ### diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index b2a612fa..71ec3d45 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -615,8 +615,6 @@ def merge_entities(entity_a: Entity, else: same = _same_id_as_resolved_entity(this, that) if same is True: - setattr(entity_a.get_property(key), attribute, - diff_r2["properties"][key][attribute]) raise_error = False if raise_error is True: raise EntityMergeConflictError( -- GitLab From 6a2c530072e4aa8c35d213ecdd58cc1dfbe82955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 2 Apr 2025 09:24:55 +0200 Subject: [PATCH 2/3] DOCS: add comments for clarification --- src/linkahead/apiutils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index 71ec3d45..dac163b8 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -587,8 +587,10 @@ def merge_entities(entity_a: Entity, raise NotImplementedError() for attribute in ("datatype", "unit", "value"): + # attribute is in r2 if (attribute in diff_r2["properties"][key] and diff_r2["properties"][key][attribute] is not None): + # but not in r1 if (attribute not in diff_r1["properties"][key] or diff_r1["properties"][key][attribute] is None): setattr(entity_a.get_property(key), attribute, @@ -596,6 +598,7 @@ def merge_entities(entity_a: Entity, elif force: setattr(entity_a.get_property(key), attribute, diff_r2["properties"][key][attribute]) + # attribute in r1 but no "force" else: raise_error = True if merge_id_with_resolved_entity is True and attribute == "value": -- GitLab From 929081bc4d24d34a678cdde9842823fa43016303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 2 Apr 2025 09:35:44 +0200 Subject: [PATCH 3/3] DOCS: correct CL statement --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ecc008..ccd78134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - convenience functions `value_matches_versionid`, `get_id_from_versionid` and `get_versionid` ### Changed ### -- `compare_entities` is now case insensitive with respect to property and - recordtype names +- `merge_entities` is does no longer replace properties in the first entity with the ones of the + second if they are considered the same due to the same ID (`merge_id_with_resolved_entity`) ### Deprecated ### -- GitLab