]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- ResultProxy.fetchall() internally uses DBAPI fetchall() for better efficiency,
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Oct 2006 17:02:12 +0000 (17:02 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Oct 2006 17:02:12 +0000 (17:02 +0000)
    added to mapper iteration as well (courtesy Michael Twomey)

CHANGES
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/orm/mapper.py

diff --git a/CHANGES b/CHANGES
index eb5f10f3daa860a880430d1f566db3e852bd4b05..721a5ef19cf40edcb3efe42774107c544615b7d0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -56,6 +56,8 @@
     - ResultProxy will close() the underlying cursor when the ResultProxy
     itself is closed.  this will auto-close cursors for ResultProxy objects
     that have had all their rows fetched (or had scalar() called).
+    - ResultProxy.fetchall() internally uses DBAPI fetchall() for better efficiency,
+    added to mapper iteration as well (courtesy Michael Twomey)
 - SQL Construction:
     - changed "for_update" parameter to accept False/True/"nowait"
     and "read", the latter two of which are interpreted only by
index 79a1909d1f52006907dad264aed5ed1085e1034e..4251c581081f04e7bac65fc06b4e89ccccbf8513 100644 (file)
@@ -632,11 +632,10 @@ class ResultProxy:
     def fetchall(self):
         """fetch all rows, just like DBAPI cursor.fetchall()."""
         l = []
-        while True:
-            v = self.fetchone()
-            if v is None:
-                return l
-            l.append(v)
+        for row in self.cursor.fetchall():
+            l.append(RowProxy(self, row))
+        self.close()
+        return l
             
     def fetchone(self):
         """fetch one row, just like DBAPI cursor.fetchone()."""
index 57c29a6308a1429825bb01c11a7c285d14c38c9f..096e1ca33b46033bfd595c3ad7b50fa53c162859 100644 (file)
@@ -659,10 +659,7 @@ class Mapper(object):
             for m in mappers:
                 otherresults.append(util.UniqueAppender([]))
                 
-        while True:
-            row = cursor.fetchone()
-            if row is None:
-                break
+        for row in cursor.fetchall():
             self._instance(context, row, result)
             i = 0
             for m in mappers: