tortoise / tortoise/tortoise-orm
Can't filter DateField by YEAR
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Have iso8601.iso8601.ParseError when try to filter DateField by YEAR.
To Reproduce
class SomeModel(MODEL):
start_date = fields.DateField()
end_date = fields.DateField()
await SomeModel.filter(start_date__year=2023)
Look like to_db_value must not validate value if used date filters
p.s. in DateTimeField all works correctly
tortoise-orm version 0.19.3 and 0.20.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the DateField query from the issue with start_date__year=2023 and observe the iso8601.iso8601.ParseError. Start by tracing DateField.to_db_value during date-filter construction, then compare the working DateTimeField path. Done means the DateField year filter works without the reported error and regression coverage is added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100