summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/loading.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-08-14 00:08:29 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-08-14 00:08:29 +0000
commit9ccf4a2f659d77c7f1aacaa4ff2b3b16889fea5e (patch)
treec30594326d1fb4b70b239c0865f1b7e627e63cc3 /lib/sqlalchemy/orm/loading.py
parentb1c3c40e54bafe686065827d5b8d92c35bc50648 (diff)
parent5fb0138a3220161703e6ab1087319a669d14e7f4 (diff)
downloadsqlalchemy-9ccf4a2f659d77c7f1aacaa4ff2b3b16889fea5e.tar.gz
Merge "Implement rudimentary asyncio support w/ asyncpg"
Diffstat (limited to 'lib/sqlalchemy/orm/loading.py')
-rw-r--r--lib/sqlalchemy/orm/loading.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py
index 2eb3e1368..fd3e92055 100644
--- a/lib/sqlalchemy/orm/loading.py
+++ b/lib/sqlalchemy/orm/loading.py
@@ -125,8 +125,21 @@ def instances(cursor, context):
if not yield_per:
break
+ if context.execution_options.get("prebuffer_rows", False):
+ # this is a bit of a hack at the moment.
+ # I would rather have some option in the result to pre-buffer
+ # internally.
+ _prebuffered = list(chunks(None))
+
+ def chunks(size):
+ return iter(_prebuffered)
+
result = ChunkedIteratorResult(
- row_metadata, chunks, source_supports_scalars=single_entity, raw=cursor
+ row_metadata,
+ chunks,
+ source_supports_scalars=single_entity,
+ raw=cursor,
+ dynamic_yield_per=cursor.context._is_server_side,
)
result._attributes = result._attributes.union(