Opened 4 weeks ago

Closed 9 days ago

Last modified 9 days ago

#37039 closed Cleanup/optimization (fixed)

Outdated QuerySet.iterator() documentation

Reported by: Lincoln Owned by: MANAS MADESHIYA
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Lincoln Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The QuerySet.iterator() documentation (https://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator) says

(internally, the default iterator calls iterator() and caches the return value)

I take "the default iterator" to mean the QuerySet __iter__() method.

This does not call iterator():

https://github.com/django/django/blob/378481165d14fea4c2a4b7717af3d7bdf9150f08/django/db/models/query.py#L417-L433

It only calls _fetch_all(), which as of this change

https://github.com/django/django/commit/f3b7c059367a4e82bbfc7e4f0d42b10975e79f0c#diff-d58ef61559dc7af5fdf7b56fee13571a4d2948e784cd608f6afeacf3ac2fb195R1075

no longer calls iterator().

So this line in the documentation is no longer accurate. I think an appropriate fix would be to simply remove that line of quoted text from the docs.

Change History (8)

comment:1 by MANAS MADESHIYA, 4 weeks ago

Cc: MANAS MADESHIYA added

comment:2 by Sarah Boyce, 4 weeks ago

Triage Stage: UnreviewedAccepted
Version: dev

Thank you for the ticket and analysis. I agree we can remove the text in the brackets

comment:3 by MANAS MADESHIYA, 4 weeks ago

Owner: set to MANAS MADESHIYA
Status: newassigned

comment:4 by MANAS MADESHIYA, 4 weeks ago

Cc: MANAS MADESHIYA removed
Has patch: set

comment:5 by Jacob Walls, 2 weeks ago

Easy pickings: set
Patch needs improvement: set

comment:6 by Jacob Walls, 9 days ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Jacob Walls <jacobtylerwalls@…>, 9 days ago

Resolution: fixed
Status: assignedclosed

In 7e7e969:

Fixed #37039 -- Removed outdated note from QuerySet.iterator() docs.

comment:8 by Jacob Walls <jacobtylerwalls@…>, 9 days ago

In 990ab01:

[6.0.x] Fixed #37039 -- Removed outdated note from QuerySet.iterator() docs.

Backport of 7e7e9691c6029f7011179ac5948b917375f3fe4e from main.

Note: See TracTickets for help on using tickets.
Back to Top