tortoise / tortoise/tortoise-orm
Model.all().limit(None) fails
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Prior to latest release( 0.17.5) Model.all().limit(None) works as it should, but now it fails with
queryset.py 422 limit
if limit < 0:
TypeError:
'<' not supported between instances of 'NoneType' and 'int'
Besides, as stated in docs it should Raises ParamsError – Limit should be non-negative number.
I think it should be non-negative number or None.
Because it's convenient to have an optional limit on your queries. And it's very annoying to write some weird dances like:
query = Model.all()
if limit:
query.limit(limit)
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 in queryset.py around line 422, where limit is compared with zero, and review the documented ParamsError behavior. Confirm that Model.all().limit(None) no longer raises the TypeError while negative limits still follow the stated validation, then verify the relevant behavior with test coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100