[SQL-CVS] r2893 - in SQLObject/trunk/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2007-08-30 14:33:08
|
Author: phd
Date: 2007-08-30 08:33:02 -0600 (Thu, 30 Aug 2007)
New Revision: 2893
Modified:
SQLObject/trunk/sqlobject/sresults.py
SQLObject/trunk/sqlobject/tests/test_select.py
Log:
Remove 'limit' from SelectResults after setting start/end so .clone() never see limit again.
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2007-08-30 14:32:38 UTC (rev 2892)
+++ SQLObject/trunk/sqlobject/sresults.py 2007-08-30 14:33:02 UTC (rev 2893)
@@ -31,7 +31,7 @@
assert not ops.get('start', None) and not ops.get('end', None), \
"'limit' cannot be used with 'start' or 'end'"
ops["start"] = 0
- ops["end"] = ops["limit"]
+ ops["end"] = ops.pop("limit")
tablesDict = sqlbuilder.tablesUsedDict(self.clause, self._getConnection().dbName)
if clauseTables:
@@ -170,13 +170,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
@@ -208,10 +208,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/trunk/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_select.py 2007-08-30 14:32:38 UTC (rev 2892)
+++ SQLObject/trunk/sqlobject/tests/test_select.py 2007-08-30 14:33:02 UTC (rev 2893)
@@ -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()
|