Initialize execution context for a Compiled construct.
(
cls,
dialect: Dialect,
connection: Connection,
dbapi_connection: PoolProxiedConnection,
execution_options: _ExecuteOptions,
compiled: SQLCompiler,
parameters: _CoreMultiExecuteParams,
invoked_statement: Executable,
extracted_parameters: Optional[Sequence[BindParameter[Any]]],
cache_hit: CacheStats = CacheStats.CACHING_DISABLED,
param_dict: _CoreSingleExecuteParams | None = None,
)
| 1442 | |
| 1443 | @classmethod |
| 1444 | def _init_compiled( |
| 1445 | cls, |
| 1446 | dialect: Dialect, |
| 1447 | connection: Connection, |
| 1448 | dbapi_connection: PoolProxiedConnection, |
| 1449 | execution_options: _ExecuteOptions, |
| 1450 | compiled: SQLCompiler, |
| 1451 | parameters: _CoreMultiExecuteParams, |
| 1452 | invoked_statement: Executable, |
| 1453 | extracted_parameters: Optional[Sequence[BindParameter[Any]]], |
| 1454 | cache_hit: CacheStats = CacheStats.CACHING_DISABLED, |
| 1455 | param_dict: _CoreSingleExecuteParams | None = None, |
| 1456 | ) -> ExecutionContext: |
| 1457 | """Initialize execution context for a Compiled construct.""" |
| 1458 | |
| 1459 | self = cls.__new__(cls) |
| 1460 | self.root_connection = connection |
| 1461 | self._dbapi_connection = dbapi_connection |
| 1462 | self.dialect = connection.dialect |
| 1463 | self.extracted_parameters = extracted_parameters |
| 1464 | self.invoked_statement = invoked_statement |
| 1465 | self.compiled = compiled |
| 1466 | self.cache_hit = cache_hit |
| 1467 | |
| 1468 | self.execution_options = execution_options |
| 1469 | |
| 1470 | self.result_column_struct = ( |
| 1471 | compiled._result_columns, |
| 1472 | compiled._ordered_columns, |
| 1473 | compiled._textual_ordered_columns, |
| 1474 | compiled._ad_hoc_textual, |
| 1475 | compiled._loose_column_name_matching, |
| 1476 | ) |
| 1477 | |
| 1478 | self.isinsert = ii = compiled.isinsert |
| 1479 | self.isupdate = iu = compiled.isupdate |
| 1480 | self.isdelete = id_ = compiled.isdelete |
| 1481 | self.is_text = compiled.isplaintext |
| 1482 | |
| 1483 | if ii or iu or id_: |
| 1484 | dml_statement = compiled.compile_state.statement # type: ignore |
| 1485 | if TYPE_CHECKING: |
| 1486 | assert isinstance(dml_statement, UpdateBase) |
| 1487 | self.is_crud = True |
| 1488 | self._is_explicit_returning = ier = bool(dml_statement._returning) |
| 1489 | self._is_implicit_returning = iir = bool( |
| 1490 | compiled.implicit_returning |
| 1491 | ) |
| 1492 | if iir and dml_statement._supplemental_returning: |
| 1493 | self._is_supplemental_returning = True |
| 1494 | |
| 1495 | # dont mix implicit and explicit returning |
| 1496 | assert not (iir and ier) |
| 1497 | |
| 1498 | if (ier or iir) and compiled.for_executemany: |
| 1499 | if ii and not self.dialect.insert_executemany_returning: |
| 1500 | raise exc.InvalidRequestError( |
| 1501 | f"Dialect {self.dialect.dialect_description} with " |
nothing calls this directly
no test coverage detected