From ac02cd8b15daaf0f8d92574b16a4e8c8dfda3ed9 Mon Sep 17 00:00:00 2001 From: Juan Carlos Jose Camacho Date: Mon, 2 Oct 2023 11:37:47 -0600 Subject: [PATCH] DH-4749 Set timezone for last_schema_sync field --- dataherald/db_scanner/models/types.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dataherald/db_scanner/models/types.py b/dataherald/db_scanner/models/types.py index af46865c..9922b12b 100644 --- a/dataherald/db_scanner/models/types.py +++ b/dataherald/db_scanner/models/types.py @@ -1,8 +1,8 @@ -from datetime import datetime +from datetime import datetime, timezone from enum import Enum from typing import Any -from pydantic import BaseModel +from pydantic import BaseModel, validator class ForeignKeyDetail(BaseModel): @@ -39,3 +39,9 @@ class TableSchemaDetail(BaseModel): last_schema_sync: datetime | None status: str = TableDescriptionStatus.SYNCHRONIZED.value error_message: str | None + + @validator("last_schema_sync", pre=True) + def parse_datetime_with_timezone(cls, value): + if not value: + return None + return value.replace(tzinfo=timezone.utc) # Set the timezone to UTC