From 1515507993f5466ddc683c7d20d6be0fcbf4b8cd Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Mon, 28 Oct 2024 09:21:53 -0300 Subject: [PATCH] fix issue with pydantic date conversion --- open_notebook/domain.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/open_notebook/domain.py b/open_notebook/domain.py index f232e4c..636a205 100644 --- a/open_notebook/domain.py +++ b/open_notebook/domain.py @@ -136,6 +136,13 @@ class ObjectModel(BaseModel): logger.exception(e) raise DatabaseOperationError(e) + @field_validator("created", "updated", mode="before") + @classmethod + def parse_datetime(cls, value): + if isinstance(value, str): + return datetime.fromisoformat(value.replace("Z", "+00:00")) + return value + class Notebook(ObjectModel): table_name: ClassVar[str] = "notebook"