[SQL-CVS] r2891 - in SQLObject/branches/0.8: docs sqlobject sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2007-08-30 14:30:56
|
Author: phd Date: 2007-08-30 08:30:52 -0600 (Thu, 30 Aug 2007) New Revision: 2891 Modified: SQLObject/branches/0.8/docs/News.txt SQLObject/branches/0.8/sqlobject/sresults.py SQLObject/branches/0.8/sqlobject/tests/test_select.py Log: Remove 'limit' from SelectResults after setting start/end so .clone() never see limit again. Modified: SQLObject/branches/0.8/docs/News.txt =================================================================== --- SQLObject/branches/0.8/docs/News.txt 2007-08-30 14:30:36 UTC (rev 2890) +++ SQLObject/branches/0.8/docs/News.txt 2007-08-30 14:30:52 UTC (rev 2891) @@ -186,6 +186,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.8/sqlobject/sresults.py =================================================================== --- SQLObject/branches/0.8/sqlobject/sresults.py 2007-08-30 14:30:36 UTC (rev 2890) +++ SQLObject/branches/0.8/sqlobject/sresults.py 2007-08-30 14:30:52 UTC (rev 2891) @@ -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.8/sqlobject/tests/test_select.py =================================================================== --- SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-08-30 14:30:36 UTC (rev 2890) +++ SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-08-30 14:30:52 UTC (rev 2891) @@ -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() |