From 53d452c6820084fac9cf30f0b3029b0d6c24231f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Tue, 8 Oct 2024 14:32:24 +0200
Subject: [PATCH] MAINT: fix datatype comparison

---
 src/linkahead/apiutils.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py
index 0c023e3a..d6549054 100644
--- a/src/linkahead/apiutils.py
+++ b/src/linkahead/apiutils.py
@@ -248,6 +248,21 @@ def compare_entities(old_entity: Entity,
         if old_entity_attr_na and new_entity_attr_na:
             continue
 
+        # treat datatype separately: if datatype is an object on one side and string on the other.
+        if attr == "datatype":
+            if (not old_entity_attr_na and not new_entity_attr_na):
+                if isinstance(oldattr, RecordType):
+                    if oldattr.name == newattr:
+                        continue
+                    if oldattr.id == newattr:
+                        continue
+                if isinstance(newattr, RecordType):
+                    if newattr.name == oldattr:
+                        continue
+                    if newattr.id == oldattr:
+                        continue
+
+
         # only one set or different values
         if ((old_entity_attr_na ^ new_entity_attr_na)
                 or (oldattr != newattr)):
@@ -257,6 +272,7 @@ def compare_entities(old_entity: Entity,
             if not new_entity_attr_na:
                 newdiff[attr] = newattr
 
+
     # value
     if (old_entity.value != new_entity.value):
         # basic comparison of value objects says they are different
-- 
GitLab