diff options
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/loading.py | 15 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 1 |
2 files changed, 14 insertions, 2 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( diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 7c254c61b..676dd438c 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -1211,7 +1211,6 @@ def _emit_insert_statements( has_all_pks, has_all_defaults, ) in records: - if value_params: result = connection.execute( statement.values(value_params), params |
