Skip to content

Conversation

@sam-dawnops
Copy link

Description

Add a dedicated ParamsError message for integer indexing on QuerySet and cover it with a regression test.

Motivation and Context

QuerySet is lazy and supports slicing, but queryset[5] currently raises a generic message. This change makes that failure mode clearer and tells users how to evaluate/query for a single item correctly.

How Has This Been Tested?

  • uv run --frozen --group test --group contrib --extra psycopg pytest -q tests/test_queryset.py
  • uv run --frozen --group dev ruff check tests/test_queryset.py tortoise/queryset.py

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing sam-dawnops:fix/queryset-integer-index-guidance (01f2d83) with develop (fe73270)

Open in CodSpeed

@coveralls
Copy link

Pull Request Test Coverage Report for Build 21883100900

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 82.483%

Files with Coverage Reduction New Missed Lines %
tortoise/queryset.py 1 96.07%
Totals Coverage Status
Change from base Build 21856593682: 0.005%
Covered Lines: 10422
Relevant Lines: 12169

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants