Django

Code

Ticket #3463 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

EmptyQuerySet's iterator() method does not return a generator

Reported by: Gary Wilson <gary.wilson@gmail.com> Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

>>> User.objects.all().iterator()
<generator object at 0xb76a714c>

>>> User.objects.none().iterator()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "./django/db/models/query.py", line 596, in iterator
    raise StopIteration
StopIteration

Attachments

iterator.diff (3.3 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 02/08/07 20:11:35.

Change History

02/08/07 20:11:35 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment iterator.diff added.

02/08/07 20:16:04 changed by Gary Wilson <gary.wilson@gmail.com>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

Patch comments:

  • Added test for none().iterator().
  • Moved the cursor() calls after the _get_sql_clause() to avoid unnecessary grabbing of a cursor.
  • EmptyQuerySet?
    • Added _get_sql_clause that always raises EmptyResultSet?.
    • Removed iterator method so that the parent method gets used instead.

02/08/07 21:53:29 changed by Gary Wilson <gary.wilson@gmail.com>

Just noting here that it was [4394] that broke the QuerySet?.iterator() interface.

02/09/07 23:38:39 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [4475]) Fixed #3463 -- EmptyQuerySet?'s iterator() now returns a generator. Thanks, Gary Wilson


Add/Change #3463 (EmptyQuerySet's iterator() method does not return a generator)




Change Properties
Action