diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-12 17:02:12 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-12 17:02:12 +0000 |
| commit | c934ae44a84fd94d805b341bfba68308e82c2384 (patch) | |
| tree | 3f71d758c1ac45c6c55c02949bcba4144f0289c2 | |
| parent | e16bfad40756e76bf4622eaeb005983a4300f32e (diff) | |
| download | sqlalchemy-c934ae44a84fd94d805b341bfba68308e82c2384.tar.gz | |
- ResultProxy.fetchall() internally uses DBAPI fetchall() for better efficiency,
added to mapper iteration as well (courtesy Michael Twomey)
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 5 |
3 files changed, 7 insertions, 9 deletions
@@ -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 diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 79a1909d1..4251c5810 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -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().""" diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 57c29a630..096e1ca33 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -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: |
