Opened 18 years ago

Closed 17 years ago

#3440 closed (fixed)

DateQuerySet.iterator not iterable if empty

Reported by: ashleywalsh@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords: qs-rf-fixed
Cc: Triage Stage: Fixed on a branch
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The changes in r4394 to support empty QuerySets does not work for DateQuerySet.iterator() because the method is not a generator, but instead returns an iterable. Instead of raising a StopIteration it should return an empty list.

Also, the other methods that are generators (e.g. QuerySet.iterator()) raise a StopIteration when they could simply return.

Attachments (3)

datequeryset.patch (555 bytes ) - added by ashleywalsh@… 18 years ago.
Diff against r4460
datequeryset.diff (556 bytes ) - added by ashleywalsh@… 18 years ago.
correct diff
date__queryset.patch (1.2 KB ) - added by zlobnyi antisvin <antisvin@…> 17 years ago.
turn DateQueryset.iterator into generator

Download all attachments as: .zip

Change History (9)

by ashleywalsh@…, 18 years ago

Attachment: datequeryset.patch added

Diff against r4460

by ashleywalsh@…, 18 years ago

Attachment: datequeryset.diff added

correct diff

comment:1 by Michael Radziej <mir@…>, 18 years ago

Resolution: duplicate
Status: newclosed

duplicate of #3463

comment:2 by zlobnyi antisvin <antisvin@…>, 17 years ago

Resolution: duplicate
Status: closedreopened
Summary: DateQuerySet.iterator not iterable if empty[patch] DateQuerySet.iterator not iterable if empty

This ticket has been marked as duplicate, but it's not. EmptyQuerySet and DateQuerySet are two different classes, and even though the former has been fixed in #3463, DateQuerySet.iterator is still not working right. It's a function at the moment, not a generator. And for empty results list it raises StopIteration that acts as an uncaught exception. This happens in admin for date_hierarchy filter for fields with null=True, for example.

by zlobnyi antisvin <antisvin@…>, 17 years ago

Attachment: date__queryset.patch added

turn DateQueryset.iterator into generator

comment:3 by Pete Crosier, 17 years ago

Summary: [patch] DateQuerySet.iterator not iterable if emptyDateQuerySet.iterator not iterable if empty

comment:4 by Jacob, 17 years ago

Triage Stage: UnreviewedFixed on a branch
Version: SVNqueryset-refactor

This is fixed in the qsrf branch.

comment:5 by Jacob, 17 years ago

Keywords: qs-rf-fixed added

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: reopenedclosed

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658

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