From dd09651585255db58bec33c5f822d4a86ebf53ce Mon Sep 17 00:00:00 2001 From: Priyank Chodisetti Date: Wed, 21 May 2025 23:20:00 -0700 Subject: [PATCH] fix(datetime): strip whitespace from datetime strings This fixes an issue where datetime strings with trailing spaces will cause an error when using the datetime expression in a formula query. --- qdrant_client/http/models/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qdrant_client/http/models/models.py b/qdrant_client/http/models/models.py index 48d95bbf0..abdb39292 100644 --- a/qdrant_client/http/models/models.py +++ b/qdrant_client/http/models/models.py @@ -1,6 +1,7 @@ from datetime import date, datetime from enum import Enum from typing import Any, Dict, List, Literal, Optional, Union +from pydantic import field_validator from uuid import UUID from pydantic import BaseModel, Field @@ -482,7 +483,11 @@ class Datatype(str, Enum): class DatetimeExpression(BaseModel, extra="forbid"): datetime: str = Field(..., description="") - + + @field_validator("datetime") + def strip_whitespace(cls, v): + """Strip any whitespace from the datetime string to prevent parsing errors.""" + return v.strip() if isinstance(v, str) else v class DatetimeIndexParams(BaseModel, extra="forbid"): type: "DatetimeIndexType" = Field(..., description="")