Ticket #10202: 10202-r9814.diff

File 10202-r9814.diff, 1.6 KB (added by Ramiro Morales, 15 years ago)

More nitpicking, Fix another Query high_mark comparison against None corner case, add a test and move tests to under regressiontests

  • django/db/models/sql/query.py

    diff -r 611e264b0305 django/db/models/sql/query.py
    a b  
    332332        # in SQL (in variants that provide them) doesn't change the COUNT
    333333        # output.
    334334        number = max(0, number - self.low_mark)
    335         if self.high_mark:
     335        if self.high_mark is not None:
    336336            number = min(number, self.high_mark - self.low_mark)
    337337
    338338        return number
     
    17331733
    17341734        Typically, this means no limits or offsets have been put on the results.
    17351735        """
    1736         return not (self.low_mark or self.high_mark)
     1736        return not self.low_mark and self.high_mark is None
    17371737
    17381738    def clear_select_fields(self):
    17391739        """
  • tests/regressiontests/queries/models.py

    diff -r 611e264b0305 tests/regressiontests/queries/models.py
    a b  
    877877>>> Item.objects.filter(created__in=[time1, time2])
    878878[<Item: one>, <Item: two>]
    879879
    880 Bug #7698 -- People like to slice with '0' as the high-water mark.
     880Bug #7698, #10202 -- People like to slice with '0' as the high-water mark.
    881881>>> Item.objects.all()[0:0]
    882882[]
    883883>>> Item.objects.all()[0:0][:10]
    884884[]
     885>>> Item.objects.all()[:0].count()
     8860
     887>>> Item.objects.all()[:0].latest('created')
     888Traceback (most recent call last):
     889    ...
     890AssertionError: Cannot change a query once a slice has been taken.
    885891
    886892Bug #7411 - saving to db must work even with partially read result set in
    887893another cursor.
Back to Top