(
cls,
session,
statement,
params,
execution_options,
bind_arguments,
is_pre_event,
)
| 504 | |
| 505 | @classmethod |
| 506 | def orm_pre_session_exec( |
| 507 | cls, |
| 508 | session, |
| 509 | statement, |
| 510 | params, |
| 511 | execution_options, |
| 512 | bind_arguments, |
| 513 | is_pre_event, |
| 514 | ): |
| 515 | # consume result-level load_options. These may have been set up |
| 516 | # in an ORMExecuteState hook |
| 517 | ( |
| 518 | load_options, |
| 519 | execution_options, |
| 520 | ) = QueryContext.default_load_options.from_execution_options( |
| 521 | "_sa_orm_load_options", |
| 522 | { |
| 523 | "populate_existing", |
| 524 | "autoflush", |
| 525 | "yield_per", |
| 526 | "identity_token", |
| 527 | "sa_top_level_orm_context", |
| 528 | }, |
| 529 | execution_options, |
| 530 | statement._execution_options, |
| 531 | ) |
| 532 | |
| 533 | # default execution options for ORM results: |
| 534 | # 1. _result_disable_adapt_to_context=True |
| 535 | # this will disable the ResultSetMetadata._adapt_to_context() |
| 536 | # step which we don't need, as we have result processors cached |
| 537 | # against the original SELECT statement before caching. |
| 538 | |
| 539 | if "sa_top_level_orm_context" in execution_options: |
| 540 | ctx = execution_options["sa_top_level_orm_context"] |
| 541 | execution_options = ctx.query._execution_options.merge_with( |
| 542 | ctx.execution_options, execution_options |
| 543 | ) |
| 544 | |
| 545 | if not execution_options: |
| 546 | execution_options = _orm_load_exec_options |
| 547 | else: |
| 548 | execution_options = execution_options.union(_orm_load_exec_options) |
| 549 | |
| 550 | # would have been placed here by legacy Query only |
| 551 | if load_options._yield_per: |
| 552 | execution_options = execution_options.union( |
| 553 | {"yield_per": load_options._yield_per} |
| 554 | ) |
| 555 | |
| 556 | if ( |
| 557 | getattr(statement._compile_options, "_current_path", None) |
| 558 | and len(statement._compile_options._current_path) > 10 |
| 559 | and execution_options.get("compiled_cache", True) is not None |
| 560 | ): |
| 561 | execution_options: util.immutabledict[str, Any] = ( |
| 562 | execution_options.union( |
| 563 | { |
no test coverage detected