summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/default.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-06-30 19:10:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-07-01 12:14:02 -0400
commit741af02893a19c879ba4d929151b9358aeb48148 (patch)
tree7b408bb82033d90cff4ba9e78ead2c0cda27411f /lib/sqlalchemy/engine/default.py
parent286e5fb649f77367883800ba4ec3d536e8031ca8 (diff)
downloadsqlalchemy-741af02893a19c879ba4d929151b9358aeb48148.tar.gz
repair yield_per for non-SS dialects and add new options
Implemented new :paramref:`_engine.Connection.execution_options.yield_per` execution option for :class:`_engine.Connection` in Core, to mirror that of the same :ref:`yield_per <orm_queryguide_yield_per>` option available in the ORM. The option sets both the :paramref:`_engine.Connection.execution_options.stream_results` option at the same time as invoking :meth:`_engine.Result.yield_per`, to provide the most common streaming result configuration which also mirrors that of the ORM use case in its usage pattern. Fixed bug in :class:`_engine.Result` where the usage of a buffered result strategy would not be used if the dialect in use did not support an explicit "server side cursor" setting, when using :paramref:`_engine.Connection.execution_options.stream_results`. This is in error as DBAPIs such as that of SQLite and Oracle already use a non-buffered result fetching scheme, which still benefits from usage of partial result fetching. The "buffered" strategy is now used in all cases where :paramref:`_engine.Connection.execution_options.stream_results` is set. Added :meth:`.FilterResult.yield_per` so that result implementations such as :class:`.MappingResult`, :class:`.ScalarResult` and :class:`.AsyncResult` have access to this method. Fixes: #8199 Change-Id: I6dde3cbe483a1bf81e945561b60f4b7d1c434750
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
-rw-r--r--lib/sqlalchemy/engine/default.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index 5d3ff8bb7..cab96eac1 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -1473,11 +1473,16 @@ class DefaultExecutionContext(ExecutionContext):
return self.dialect.supports_sane_multi_rowcount
def _setup_result_proxy(self):
+ exec_opt = self.execution_options
+
if self.is_crud or self.is_text:
result = self._setup_dml_or_text_result()
+ yp = sr = False
else:
+ yp = exec_opt.get("yield_per", None)
+ sr = self._is_server_side or exec_opt.get("stream_results", False)
strategy = self.cursor_fetch_strategy
- if self._is_server_side and strategy is _cursor._DEFAULT_FETCH:
+ if sr and strategy is _cursor._DEFAULT_FETCH:
strategy = _cursor.BufferedRowCursorFetchStrategy(
self.cursor, self.execution_options
)
@@ -1501,6 +1506,9 @@ class DefaultExecutionContext(ExecutionContext):
self._soft_closed = result._soft_closed
+ if yp:
+ result = result.yield_per(yp)
+
return result
def _setup_out_parameters(self, result):