diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2021-11-02 21:42:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-11-02 21:42:05 +0000 |
| commit | 37bc1285c5bddf1e1b3a5830c530139e6fdd4bc4 (patch) | |
| tree | d9ba2604cbc02d2fb43b737adc4a80c3b54e2f33 /lib/sqlalchemy/engine/cursor.py | |
| parent | 72780bae3377c45abb03cb62b638b84ed04375e2 (diff) | |
| parent | 33824a9c06ca555ad208a9925bc7b40fe489fc72 (diff) | |
| download | sqlalchemy-37bc1285c5bddf1e1b3a5830c530139e6fdd4bc4.tar.gz | |
Merge "ensure soft_close occurs for fetchmany with server side cursor" into main
Diffstat (limited to 'lib/sqlalchemy/engine/cursor.py')
| -rw-r--r-- | lib/sqlalchemy/engine/cursor.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/engine/cursor.py b/lib/sqlalchemy/engine/cursor.py index 071f95cff..0099d69ff 100644 --- a/lib/sqlalchemy/engine/cursor.py +++ b/lib/sqlalchemy/engine/cursor.py @@ -923,6 +923,8 @@ class BufferedRowCursorFetchStrategy(CursorFetchStrategy): ) def _buffer_rows(self, result, dbapi_cursor): + """this is currently used only by fetchone().""" + size = self._bufsize try: if size < 1: @@ -975,9 +977,14 @@ class BufferedRowCursorFetchStrategy(CursorFetchStrategy): lb = len(buf) if size > lb: try: - buf.extend(dbapi_cursor.fetchmany(size - lb)) + new = dbapi_cursor.fetchmany(size - lb) except BaseException as e: self.handle_exception(result, dbapi_cursor, e) + else: + if not new: + result._soft_close() + else: + buf.extend(new) result = buf[0:size] self._rowbuffer = collections.deque(buf[size:]) @@ -1216,7 +1223,6 @@ class BaseCursorResult(object): """ - if (not hard and self._soft_closed) or (hard and self.closed): return |
