Fix naive datetime fallbacks in repository layer
Use UTC-aware datetimes consistently to prevent TypeError when comparing aware and naive datetime objects.
This commit is contained in:
parent
87269b9393
commit
dbcd9dfa4c
2 changed files with 5 additions and 3 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from domain.models import AnalysisJob, AnalysisStatus
|
||||
from persistence.database import get_connection
|
||||
|
|
@ -29,7 +29,7 @@ def _row_to_job(row) -> AnalysisJob:
|
|||
error_message=row["error_message"],
|
||||
started_at=_parse_dt(row["started_at"]),
|
||||
completed_at=_parse_dt(row["completed_at"]),
|
||||
created_at=_parse_dt(row["created_at"]) or datetime.now(),
|
||||
created_at=_parse_dt(row["created_at"]) or datetime.now(UTC),
|
||||
document_filename=row["filename"] if "filename" in keys else None,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from domain.models import Document
|
||||
from persistence.database import get_connection
|
||||
|
|
@ -12,6 +12,8 @@ def _row_to_document(row) -> Document:
|
|||
created = row["created_at"]
|
||||
if isinstance(created, str):
|
||||
created = datetime.fromisoformat(created)
|
||||
if created.tzinfo is None:
|
||||
created = created.replace(tzinfo=UTC)
|
||||
return Document(
|
||||
id=row["id"],
|
||||
filename=row["filename"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue