Author: phd
Date: 2007-08-30 08:32:38 -0600 (Thu, 30 Aug 2007)
New Revision: 2892
Modified:
SQLObject/branches/0.9/docs/News.txt
SQLObject/branches/0.9/sqlobject/sresults.py
SQLObject/branches/0.9/sqlobject/tests/test_select.py
Log:
Remove 'limit' from SelectResults after setting start/end so .clone() never see limit again.
Modified: SQLObject/branches/0.9/docs/News.txt
===================================================================
--- SQLObject/branches/0.9/docs/News.txt 2007-08-30 14:30:52 UTC (rev 2891)
+++ SQLObject/branches/0.9/docs/News.txt 2007-08-30 14:32:38 UTC (rev 2892)
@@ -10,6 +10,8 @@
SQLObject 0.9.2
===============
+* A number of changes ported from `SQLObject 0.7.9`_.
+
SQLObject 0.9.1
===============
@@ -258,6 +260,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.9/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/sresults.py 2007-08-30 14:30:52 UTC (rev 2891)
+++ SQLObject/branches/0.9/sqlobject/sresults.py 2007-08-30 14:32:38 UTC (rev 2892)
@@ -36,6 +36,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))
@@ -150,13 +151,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
@@ -183,10 +184,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.9/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/tests/test_select.py 2007-08-30 14:30:52 UTC (rev 2891)
+++ SQLObject/branches/0.9/sqlobject/tests/test_select.py 2007-08-30 14:32:38 UTC (rev 2892)
@@ -77,8 +77,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()
|