Execute a sql.ClauseElement object.
(
self,
elem: Executable,
distilled_parameters: _CoreMultiExecuteParams,
execution_options: CoreExecuteOptionsParameter,
)
| 1616 | return elem, distilled_params, event_multiparams, event_params |
| 1617 | |
| 1618 | def _execute_clauseelement( |
| 1619 | self, |
| 1620 | elem: Executable, |
| 1621 | distilled_parameters: _CoreMultiExecuteParams, |
| 1622 | execution_options: CoreExecuteOptionsParameter, |
| 1623 | ) -> CursorResult[Unpack[TupleAny]]: |
| 1624 | """Execute a sql.ClauseElement object.""" |
| 1625 | |
| 1626 | exec_opts = elem._execution_options.merge_with( |
| 1627 | self._execution_options, execution_options |
| 1628 | ) |
| 1629 | |
| 1630 | has_events = self._has_events or self.engine._has_events |
| 1631 | if has_events: |
| 1632 | ( |
| 1633 | elem, |
| 1634 | distilled_parameters, |
| 1635 | event_multiparams, |
| 1636 | event_params, |
| 1637 | ) = self._invoke_before_exec_event( |
| 1638 | elem, distilled_parameters, exec_opts |
| 1639 | ) |
| 1640 | |
| 1641 | if distilled_parameters: |
| 1642 | # ensure we don't retain a link to the view object for keys() |
| 1643 | # which links to the values, which we don't want to cache |
| 1644 | keys = sorted(distilled_parameters[0]) |
| 1645 | for_executemany = len(distilled_parameters) > 1 |
| 1646 | else: |
| 1647 | keys = [] |
| 1648 | for_executemany = False |
| 1649 | |
| 1650 | dialect = self.dialect |
| 1651 | |
| 1652 | schema_translate_map = exec_opts.get("schema_translate_map", None) |
| 1653 | |
| 1654 | compiled_cache: Optional[CompiledCacheType] = exec_opts.get( |
| 1655 | "compiled_cache", self.engine._compiled_cache |
| 1656 | ) |
| 1657 | |
| 1658 | compiled_sql, extracted_params, param_dict, cache_hit = ( |
| 1659 | elem._compile_w_cache( |
| 1660 | dialect=dialect, |
| 1661 | compiled_cache=compiled_cache, |
| 1662 | column_keys=keys, |
| 1663 | for_executemany=for_executemany, |
| 1664 | schema_translate_map=schema_translate_map, |
| 1665 | linting=self.dialect.compiler_linting | compiler.WARN_LINTING, |
| 1666 | ) |
| 1667 | ) |
| 1668 | ret = self._execute_context( |
| 1669 | dialect, |
| 1670 | dialect.execution_ctx_cls._init_compiled, |
| 1671 | compiled_sql, |
| 1672 | distilled_parameters, |
| 1673 | exec_opts, |
| 1674 | compiled_sql, |
| 1675 | distilled_parameters, |
no test coverage detected