Code

Opened 7 years ago

Closed 6 years ago

#3440 closed (fixed)

DateQuerySet.iterator not iterable if empty

Reported by: ashleywalsh@… Owned by: adrian
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: UI/UX:

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

Download all attachments as: .zip

Change History (9)

Changed 7 years ago by ashleywalsh@…

Diff against r4460

Changed 7 years ago by ashleywalsh@…

correct diff

comment:1 Changed 7 years ago by Michael Radziej <mir@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

duplicate of #3463

comment:2 Changed 7 years ago by zlobnyi antisvin <antisvin@…>

  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Summary changed from DateQuerySet.iterator not iterable if empty to [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.

Changed 7 years ago by zlobnyi antisvin <antisvin@…>

turn DateQueryset.iterator into generator

comment:3 Changed 6 years ago by PJCrosier

  • Summary changed from [patch] DateQuerySet.iterator not iterable if empty to DateQuerySet.iterator not iterable if empty

comment:4 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Fixed on a branch
  • Version changed from SVN to queryset-refactor

This is fixed in the qsrf branch.

comment:5 Changed 6 years ago by jacob

  • Keywords qs-rf-fixed added

comment:6 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

(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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.