We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using PydanticDTO with a datetime field and default_factory does not work anymore since #3721. The get request returns Bad Request
PydanticDTO
datetime
default_factory
get
No response
from datetime import datetime import pydantic as pydantic_v2 from litestar import post from litestar.contrib.pydantic.pydantic_dto_factory import PydanticDTO from litestar.testing import create_test_client def test_pydanticdto_with_default_factory() -> None: _now = datetime.fromisoformat("2024-01-01T12:42:42") class User(pydantic_v2.BaseModel): timestamp: datetime = pydantic_v2.Field(default_factory=lambda: _now) @post("/", dto=PydanticDTO[User]) async def create_user(data: User) -> User: return data with create_test_client(create_user) as client: response = client.post("/", json={}) assert response.status_code == 201 assert User.model_validate(response.json()) == User.model_validate({}) test_pydanticdto_with_default_factory()
Execute the code above.
2.12.0
Note
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
Using
PydanticDTO
with adatetime
field anddefault_factory
does not work anymore since #3721.The
get
request returns Bad RequestURL to code causing the issue
No response
MCVE
Steps to reproduce
Litestar Version
2.12.0
Platform
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: