mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
Fixed limit/offset computations.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6118 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cc9d519424
commit
a7d01ec9b4
@ -208,7 +208,7 @@ class Query(object):
|
|||||||
if self.high_mark:
|
if self.high_mark:
|
||||||
result.append('LIMIT %d' % (self.high_mark - self.low_mark))
|
result.append('LIMIT %d' % (self.high_mark - self.low_mark))
|
||||||
if self.low_mark:
|
if self.low_mark:
|
||||||
assert self.high_mark, "OFFSET not allowed without LIMIT."
|
assert self.high_mark, "'offset' is not allowed without 'limit'"
|
||||||
result.append('OFFSET %d' % self.low_mark)
|
result.append('OFFSET %d' % self.low_mark)
|
||||||
|
|
||||||
params.extend(self.extra_params)
|
params.extend(self.extra_params)
|
||||||
@ -632,10 +632,15 @@ class Query(object):
|
|||||||
clamped to any existing high value.
|
clamped to any existing high value.
|
||||||
"""
|
"""
|
||||||
if high:
|
if high:
|
||||||
# None (high_mark's default) is less than any number, so this works.
|
if self.high_mark:
|
||||||
self.high_mark = max(self.high_mark, high)
|
self.high_mark = min(self.high_mark, self.low_mark + high)
|
||||||
|
else:
|
||||||
|
self.high_mark = self.low_mark + high
|
||||||
if low:
|
if low:
|
||||||
self.low_mark = max(self.high_mark, self.low_mark + low)
|
if self.high_mark:
|
||||||
|
self.low_mark = min(self.high_mark, self.low_mark + low)
|
||||||
|
else:
|
||||||
|
self.low_mark = self.low_mark + low
|
||||||
|
|
||||||
def clear_limits(self):
|
def clear_limits(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user