]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
merge r6521 from trunk, [ticket:1632]
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2009 02:38:48 +0000 (02:38 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2009 02:38:48 +0000 (02:38 +0000)
CHANGES
lib/sqlalchemy/pool.py
test/engine/test_pool.py

diff --git a/CHANGES b/CHANGES
index 9bad50eb515e43a207c99cac2fc7557f64cef59f..49e02e2aabfb7a6d40caf8ebb1e03f276fd892c7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -56,6 +56,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 c4e1af20cf3fb27786d6154f2c7913e32c508315..7412b1a3c84947a34168fb8c325eae2a9c857892 100644 (file)
@@ -429,7 +429,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 d135ad337acc70452024450d6b2640b8e4cfce02..cffa42098bbb186c00f193124e98c09174e03048 100644 (file)
@@ -1,7 +1,8 @@
 import threading, time, gc
 from sqlalchemy import pool, interfaces
 import sqlalchemy as tsa
-from sqlalchemy.test import TestBase
+from sqlalchemy.test import TestBase, testing
+from sqlalchemy.test.testing import eq_
 
 
 mcid = 1
@@ -75,7 +76,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)