Ticket #3440: date__queryset.patch

File date__queryset.patch, 1.2 KB (added by zlobnyi antisvin <antisvin@…>, 8 years ago)

turn DateQueryset.iterator into generator

  • django/db/models/query.py

     
    665665
    666666        has_resolve_columns = hasattr(self, 'resolve_columns')
    667667        needs_datetime_string_cast = connection.features.needs_datetime_string_cast
    668         dates = []
    669668        # It would be better to use self._field here instead of DateTimeField(),
    670669        # but in Oracle that will result in a list of datetime.date instead of
    671670        # datetime.datetime.
     
    673672        while 1:
    674673            rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
    675674            if not rows:
    676                 return dates
     675                raise StopIteration
    677676            for row in rows:
    678677                date = row[0]
    679678                if has_resolve_columns:
    680679                    date = self.resolve_columns([date], fields)[0]
    681680                elif needs_datetime_string_cast:
    682681                    date = typecast_timestamp(str(date))
    683                 dates.append(date)
     682                yield date
    684683
    685684    def _clone(self, klass=None, **kwargs):
    686685        c = super(DateQuerySet, self)._clone(klass, **kwargs)
Back to Top