From: Mike Bayer Date: Thu, 18 May 2006 14:16:56 +0000 (+0000) Subject: c. martinez' fix to slicing logic X-Git-Tag: rel_0_2_0~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=030c50d20d7dfd135570e6b72edca9f3dfe14123;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git c. martinez' fix to slicing logic --- diff --git a/lib/sqlalchemy/mods/selectresults.py b/lib/sqlalchemy/mods/selectresults.py index 5528c7bf66..bff436aceb 100644 --- a/lib/sqlalchemy/mods/selectresults.py +++ b/lib/sqlalchemy/mods/selectresults.py @@ -70,11 +70,11 @@ class SelectResults(object): else: res = self.clone() if start is not None and stop is not None: - res._ops.update(dict(offset=start, limit=stop-start)) + res._ops.update(dict(offset=self._ops.get('offset', 0)+start, limit=stop-start)) elif start is None and stop is not None: res._ops.update(dict(limit=stop)) elif start is not None and stop is None: - res._ops.update(dict(offset=start)) + res._ops.update(dict(offset=self._ops.get('offset', 0)+start)) if item.step is not None: return list(res)[None:None:item.step] else: diff --git a/test/selectresults.py b/test/selectresults.py index 2e603580ac..d049186837 100644 --- a/test/selectresults.py +++ b/test/selectresults.py @@ -37,6 +37,7 @@ class SelectResultsTest(PersistTest): assert list(self.res[:10]) == self.orig[:10] assert list(self.res[10:40:3]) == self.orig[10:40:3] assert list(self.res[-5:]) == self.orig[-5:] + assert self.res[10:20][5] == self.orig[10:20][5] def test_aggregate(self): assert self.res.count() == 100