Django

Code

Changeset 7885

Show
Ignore:
Timestamp:
07/11/08 07:43:27 (4 months ago)
Author:
mtredinnick
Message:

Fixed #7698 -- Handle '0' correctly when used as the upper bound of a slice.
Based on a patch from enoksrd.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/sql/query.py

    r7835 r7885  
    286286        # FIXME: Pull this out to make life easier for Oracle et al. 
    287287        if with_limits: 
    288             if self.high_mark
     288            if self.high_mark is not None
    289289                result.append('LIMIT %d' % (self.high_mark - self.low_mark)) 
    290             if self.low_mark
    291                 if not self.high_mark
     290            if self.low_mark is not None
     291                if self.high_mark is None
    292292                    val = self.connection.ops.no_limit_value() 
    293293                    if val: 
     
    13821382        clamped to any existing high value. 
    13831383        """ 
    1384         if high
     1384        if high is not None
    13851385            if self.high_mark: 
    13861386                self.high_mark = min(self.high_mark, self.low_mark + high) 
    13871387            else: 
    13881388                self.high_mark = self.low_mark + high 
    1389         if low
     1389        if low is not None
    13901390            if self.high_mark: 
    13911391                self.low_mark = min(self.high_mark, self.low_mark + low) 
  • django/trunk/tests/regressiontests/queries/models.py

    r7883 r7885  
    811811[<Item: one>, <Item: two>] 
    812812 
     813Bug #7698 -- People like to slice with '0' as the high-water mark. 
     814>>> Item.objects.all()[0:0] 
     815[] 
     816 
    813817"""} 
    814818