From 970a126aef5e9ebc191c5a223bcbbaa67054add0 Mon Sep 17 00:00:00 2001
From: Florian Spreckelsen <f.spreckelsen@indiscale.com>
Date: Tue, 20 Aug 2024 15:07:45 +0200
Subject: [PATCH] FIX: Handle datetime.date(time) correctly in _parse_value

---
 src/linkahead/common/models.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py
index 96851f34..a8144286 100644
--- a/src/linkahead/common/models.py
+++ b/src/linkahead/common/models.py
@@ -39,6 +39,7 @@ import re
 import sys
 from builtins import str
 from copy import deepcopy
+from datetime import date, datetime
 from functools import cmp_to_key
 from hashlib import sha512
 from os import listdir
@@ -50,7 +51,6 @@ from typing import TYPE_CHECKING
 from typing import Any, Final, Literal, Optional, TextIO, Union
 
 if TYPE_CHECKING:
-    from datetime import datetime
     from .datatype import DATATYPE
     from tempfile import _TemporaryFileWrapper
     from io import BufferedWriter
@@ -1687,6 +1687,9 @@ def _parse_value(datatype, value):
         if isinstance(value, str):
             return value
 
+    if datatype == DATETIME and (isinstance(value, date) or isinstance(value, datetime)):
+        return value
+
     # deal with collections
     if isinstance(datatype, str):
         matcher = re.compile(r"^(?P<col>[^<]+)<(?P<dt>[^>]+)>$")
-- 
GitLab