tortoise / tortoise/tortoise-orm
Bug in nested QuerySet when defined via `objects = CustomManager(...)`
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
In continuation to https://github.com/tortoise/tortoise-orm/issues/864
Now it works if manager is defined like this:
class ManagerModel(AbstractManagerModel):
class Meta:
manager = StatusManager(queryset_cls=StatusQuerySet)
(Thats from tests/testmodels.py)
However it will not work if manager is defined like this:
class ManagerModel(AbstractManagerModel):
objects = StatusManager(queryset_cls=StatusQuerySet)
However it works, when in tortoise/queryset.py:321
- queryset = self.__class__.__new__(QuerySet)
+ queryset = self.__class__.__new__(self.__class__)
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 with the ManagerModel definitions in tests/testmodels.py and inspect tortoise/queryset.py around line 321. Reproduce the difference between defining StatusManager through Meta.manager and objects, then verify that the objects form preserves the StatusQuerySet behavior shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100