Author: mtredinnick
Date: 2007-09-12 22:11:44 -0500 (Wed, 12 Sep 2007)
New Revision: 6118

Modified:
   django/branches/queryset-refactor/django/db/models/sql/query.py
Log:
Fixed limit/offset computations.


Modified: django/branches/queryset-refactor/django/db/models/sql/query.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/sql/query.py     
2007-09-13 02:56:31 UTC (rev 6117)
+++ django/branches/queryset-refactor/django/db/models/sql/query.py     
2007-09-13 03:11:44 UTC (rev 6118)
@@ -208,7 +208,7 @@
             if self.high_mark:
                 result.append('LIMIT %d' % (self.high_mark - 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)
 
         params.extend(self.extra_params)
@@ -632,10 +632,15 @@
         clamped to any existing high value.
         """
         if high:
-            # None (high_mark's default) is less than any number, so this 
works.
-            self.high_mark = max(self.high_mark, high)
+            if self.high_mark:
+                self.high_mark = min(self.high_mark, self.low_mark + high)
+            else:
+                self.high_mark = self.low_mark + high
         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):
         """


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to