From: Mike Bayer Date: Thu, 3 Dec 2009 02:34:47 +0000 (+0000) Subject: - The cursor associated with connection pool connections X-Git-Tag: rel_0_6beta1~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=648e0eb70c8f4e3db3b632409924a58d76d25008;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - The cursor associated with connection pool connections (i.e. _CursorFairy) now proxies `__iter__()` to the underlying cursor correctly. [ticket:1632] --- diff --git a/CHANGES b/CHANGES index 2c2995f09d..a8d4a0109e 100644 --- a/CHANGES +++ b/CHANGES @@ -764,6 +764,10 @@ CHANGES elements to render correctly even if they all render identically, such as "qmark" style bind parameters. [ticket:1574] + + - The cursor associated with connection pool connections + (i.e. _CursorFairy) now proxies `__iter__()` to the + underlying cursor correctly. [ticket:1632] - postgresql - Added support for reflecting the DOUBLE PRECISION type, diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index a67676143b..43b8623bc3 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -440,7 +440,10 @@ class _CursorFairy(object): def invalidate(self, e=None): self._parent.invalidate(e=e) - + + def __iter__(self): + return iter(self.cursor) + def close(self): try: self.cursor.close() diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index a7fe4dadea..937af75994 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -73,7 +73,14 @@ class PoolTest(PoolTestBase): self.assert_(connection.cursor() is not None) self.assert_(connection is not connection2) - + def test_cursor_iterable(self): + conn = testing.db.raw_connection() + cursor = conn.cursor() + cursor.execute("select 1") + expected = [(1,)] + for row in cursor: + eq_(row, expected.pop(0)) + def testthreadlocal_del(self): self._do_testthreadlocal(useclose=False)