From cd1ee89d0799c543b4a2b672dde701fd46c706f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Thu, 8 Feb 2024 16:30:06 +0100
Subject: [PATCH] MAINT: do not convert to string if target datatype is correct

---
 src/linkahead/common/models.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py
index 38c13490..4d7798d4 100644
--- a/src/linkahead/common/models.py
+++ b/src/linkahead/common/models.py
@@ -63,8 +63,7 @@ from ..exceptions import (AmbiguousEntityError, AuthorizationError,
                           UniqueNamesError, UnqualifiedParentsError,
                           UnqualifiedPropertiesError)
 from .datatype import (BOOLEAN, DATETIME, DOUBLE, INTEGER, TEXT,
-                       get_list_datatype,
-                       is_list_datatype, is_reference)
+                       get_list_datatype, is_list_datatype, is_reference)
 from .state import State
 from .timezone import TimeZone
 from .utils import uuid, xml2str
@@ -1503,7 +1502,12 @@ def _parse_value(datatype, value):
         return float(value)
 
     if datatype == INTEGER:
-        return int(str(value))
+        if isinstance(value, int):
+            return value
+        elif isinstance(value, float):
+            return int(value)
+        else:
+            return int(str(value))
 
     if datatype == BOOLEAN:
         if str(value).lower() == "true":
-- 
GitLab