]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Restored "active rowcount" fetch before ResultProxy
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Nov 2008 16:42:35 +0000 (16:42 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Nov 2008 16:42:35 +0000 (16:42 +0000)
autocloses the cursor.  This was removed in 0.5rc3.

CHANGES
lib/sqlalchemy/engine/base.py
test/engine/reconnect.py

diff --git a/CHANGES b/CHANGES
index 373a56559f46536f33409e1b90208d8159da81e3..a05bfa4557b2ca1d37b226e780488a880c7ad4df 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -36,6 +36,9 @@ CHANGES
 - sql
     - Removed the 'properties' attribute of the 
       Connection object, Connection.info should be used.
+    
+    - Restored "active rowcount" fetch before ResultProxy
+      autocloses the cursor.  This was removed in 0.5rc3.
       
 - access
     - Added support for Currency type.
index 832903a735b8c3ebf8f2fca380de1c5bd2c1fcda..d22e21cfe8fd604b925bdec43461f03ab6497c7c 100644 (file)
@@ -1382,7 +1382,10 @@ class ResultProxy(object):
     
     @property
     def rowcount(self):
-        return self.context.get_rowcount()
+        if self._rowcount is None:
+            return self.context.get_rowcount()
+        else:
+            return self._rowcount
 
     @property
     def lastrowid(self):
@@ -1395,10 +1398,13 @@ class ResultProxy(object):
     def _init_metadata(self):
         metadata = self.cursor.description
         if metadata is None:
-            # no results, close
+            # no results, get rowcount (which requires open cursor on some DB's such as firebird),
+            # then close
+            self._rowcount = self.context.get_rowcount()
             self.close()
             return
             
+        self._rowcount = None
         self._props = util.PopulateDict(None)
         self._props.creator = self.__key_fallback()
         self.keys = []
index d50267a1f24ea2bc134a91d56eaa923ae90a8327..936ea97e49b755ab18cb1219cabe8bb2b6d9bd79 100644 (file)
@@ -36,7 +36,7 @@ class MockConnection(object):
 class MockCursor(object):
     def __init__(self, parent):
         self.explode = parent.explode
-        self.description = None
+        self.description = ()
     def execute(self, *args, **kwargs):
         if self.explode[0]:
             raise MockDisconnect("Lost the DB connection")