tortoise / tortoise/tortoise-orm
Subclassing of QuerySet
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Is there any plans for allowing developers to easily subclass querysets like in django? Currently, it seems like any subclass of a queryset returns the queryset, not the subclass.
Example:
class CustomQuerySet(QuerySet):
def get_active():
CustomQuerySet.filter().get_active()
The above is not chainable since .filter() returns an instance of QuerySet not CustomQuerySet.
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 at the QuerySet implementation and trace how filter constructs and returns querysets. Compare the intended chainability with the CustomQuerySet.get_active example, then determine how subclass preservation should be tested; the issue does not name a file or existing test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100