tortoise / tortoise/tortoise-orm
Filtering arguments as dictionnary
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the solution you'd like
I'd like to be able to pass a dictionnary to a field argument of the filter method like so :
teams = await Team.filter(name= {
"icontains": "CON",
"lt": 6,
"startswith": "a"
})
Describe alternatives you've considered
Right now, the way to do it is :
teams = await Team.filter(name__icontains='CON', id__lt=6, name__startswith="a")
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
Start by reading the existing filter() API and its double-underscore lookup handling. Compare the requested dictionary form with the current equivalent using name__icontains, id__lt, and name__startswith. Done means the dictionary syntax supports the requested lookups without removing the existing form, with tests covering the examples shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100