summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/cursor.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/engine/cursor.py')
-rw-r--r--lib/sqlalchemy/engine/cursor.py10
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