tortoise / tortoise/tortoise-orm
Support Django's `.extra(select={...})` feature
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
In Django, I can add related table field into current selected field results like this:
f1 = "SELECT COUNT(*) FROM app_sale1_pp_by_cat WHERE cat_id = app_GoodsCategory.id"
objs = GoodsCategory.objects.filter(is_leaf=True) \
.extra(select={'company_count':f1})
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 reviewing how Tortoise ORM builds selected fields and how its query API could represent Django's .extra(select={...}) example. Compare the requested related-table count with existing selection support, then define the supported API and verification cases before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100