Author: phd
Date: 2007-08-30 08:30:36 -0600 (Thu, 30 Aug 2007)
New Revision: 2890
Modified:
SQLObject/branches/0.7/docs/News.txt
SQLObject/branches/0.7/sqlobject/sresults.py
SQLObject/branches/0.7/sqlobject/tests/test_select.py
Log:
Remove 'limit' from SelectResults after setting start/end so .clone() never see limit again.
Modified: SQLObject/branches/0.7/docs/News.txt
===================================================================
--- SQLObject/branches/0.7/docs/News.txt 2007-08-23 16:54:33 UTC (rev 2889)
+++ SQLObject/branches/0.7/docs/News.txt 2007-08-30 14:30:36 UTC (rev 2890)
@@ -10,6 +10,12 @@
SQLObject 0.7.9
===============
+Bug Fixes
+---------
+
+* Remove 'limit' from SelectResults after setting start/end so .clone()
+ never see limit again.
+
Other Changes
-------------
Modified: SQLObject/branches/0.7/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/0.7/sqlobject/sresults.py 2007-08-23 16:54:33 UTC (rev 2889)
+++ SQLObject/branches/0.7/sqlobject/sresults.py 2007-08-30 14:30:36 UTC (rev 2890)
@@ -35,6 +35,7 @@
"'limit' cannot be used with 'start' or 'end'"
ops["start"] = 0
ops["end"] = ops["limit"]
+ del ops["limit"]
def __repr__(self):
return "<%s at %x>" % (self.__class__.__name__, id(self))
@@ -145,13 +146,13 @@
if self.ops.get('end', None) is not None \
and self.ops['end'] < end:
end = self.ops['end']
- return self.clone(limit=None, start=start, end=end)
+ return self.clone(start=start, end=end)
else:
if value < 0:
return list(iter(self))[value]
else:
start = self.ops.get('start', 0) + value
- return list(self.clone(limit=None, start=start, end=start+1))[0]
+ return list(self.clone(start=start, end=start+1))[0]
def __iter__(self):
# @@: This could be optimized, using a simpler algorithm
@@ -178,10 +179,11 @@
def count(self):
""" Counting elements of current select results """
- assert not self.ops.get('limit'), "'limit' is meaningless with 'distinct'"
+ assert not self.ops.get('start') and not self.ops.get('end'), \
+ "start/end/limit have no meaning with 'count'"
assert not (self.ops.get('distinct') and (self.ops.get('start')
or self.ops.get('end'))), \
- "distinct-counting of sliced objects is not supported"
+ "distinct-counting of sliced objects is not supported"
if self.ops.get('distinct'):
# Column must be specified, so we are using unique ID column.
# COUNT(DISTINCT column) is supported by MySQL and PostgreSQL,
Modified: SQLObject/branches/0.7/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.7/sqlobject/tests/test_select.py 2007-08-23 16:54:33 UTC (rev 2889)
+++ SQLObject/branches/0.7/sqlobject/tests/test_select.py 2007-08-30 14:30:36 UTC (rev 2890)
@@ -75,8 +75,7 @@
def test_05_select_limit():
setupIter()
assert len(list(IterTest.select(limit=2))) == 2
- raises(AssertionError, IterTest.select(limit=2).distinct)
- raises(AssertionError, IterTest.select(limit=2).clone, start=1)
+ raises(AssertionError, IterTest.select(limit=2).count)
def test_06_like():
setupIter()
|