]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The cursor associated with connection pool connections
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2009 02:34:47 +0000 (02:34 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2009 02:34:47 +0000 (02:34 +0000)
(i.e. _CursorFairy) now proxies `__iter__()` to the
underlying cursor correctly. [ticket:1632]

CHANGES
lib/sqlalchemy/pool.py
test/engine/test_pool.py

diff --git a/CHANGES b/CHANGES
index 2c2995f09dac9de46c702d9fbdfc80d8c32f6cd1..a8d4a0109e74d2a0354c0a537656142ff6945bda 100644 (file)
--- 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,
index a67676143b1d930c05b336762c649005d3988b53..43b8623bc388065f7c7563b841ad92b2fef6aa85 100644 (file)
@@ -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()
index a7fe4dadea7f039c34e3d70a89917a2ca88f268e..937af759942a30b47699fd666e0b727f8121fd32 100644 (file)
@@ -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)