class ORMExecuteState(util.MemoizedSlots): (source)
Represents a call to the :meth:`_orm.Session.execute` method, as passed to the :meth:`.SessionEvents.do_orm_execute` event hook. .. versionadded:: 1.4 .. seealso:: :ref:`session_execute_events` - top level documentation on how to use :meth:`_orm.SessionEvents.do_orm_execute`
Method | __init__ |
Construct a new :class:`_orm.ORMExecuteState`. |
Method | invoke |
Execute the statement represented by this :class:`.ORMExecuteState`, without re-invoking events that have already proceeded. |
Method | update |
Update the local execution options with new values. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | bind |
The dictionary passed as the :paramref:`_orm.Session.execute.bind_arguments` dictionary. |
Instance Variable | execution |
The complete dictionary of current execution options. |
Instance Variable | local |
Dictionary view of the execution options passed to the :meth:`.Session.execute` method. |
Instance Variable | parameters |
Dictionary of parameters that was passed to :meth:`_orm.Session.execute`. |
Instance Variable | session |
The :class:`_orm.Session` in use. |
Instance Variable | statement |
The SQL statement being invoked. |
Property | all |
Return a sequence of all :class:`_orm.Mapper` objects that are involved at the top level of this statement. |
Property | bind |
Return the :class:`_orm.Mapper` that is the primary "bind" mapper. |
Property | is |
Return True if the operation is refreshing column-oriented attributes on an existing ORM object. |
Property | is |
return True if this is a DELETE operation. |
Property | is |
return True if the parameters are a multi-element list of dictionaries with more than one dictionary. |
Property | is |
return True if this is an INSERT operation. |
Property | is |
return True if the operation is an ORM statement. |
Property | is |
Return True if this load is loading objects on behalf of a relationship. |
Property | is |
return True if this is a SELECT operation. |
Property | is |
return True if this is an UPDATE operation. |
Property | lazy |
An :class:`.InstanceState` that is using this statement execution for a lazy load operation. |
Property | load |
Return the load_options that will be used for this execution. |
Property | loader |
Return the :class:`.PathRegistry` for the current load path. |
Property | update |
Return the update_delete_options that will be used for this execution. |
Property | user |
The sequence of :class:`.UserDefinedOptions` that have been associated with the statement being invoked. |
Method | _orm |
Undocumented |
Method | _remaining |
Undocumented |
Class Variable | _starting |
Undocumented |
Class Variable | _update |
Undocumented |
Instance Variable | _compile |
Undocumented |
Instance Variable | _events |
Undocumented |
Property | _is |
Undocumented |
Property | _non |
Undocumented |
Inherited from MemoizedSlots
:
Method | __getattr__ |
Undocumented |
Method | _fallback |
Undocumented |
Session
, statement: Executable
, parameters: Optional[ _CoreAnyExecuteParams]
, execution_options: _ExecuteOptions
, bind_arguments: _BindArguments
, compile_state_cls: Optional[ Type[ ORMCompileState]]
, events_todo: List[ _InstanceLevelDispatch[ Session]]
):
(source)
¶
Construct a new :class:`_orm.ORMExecuteState`. this object is constructed internally.
Optional[ Executable]
= None, params: Optional[ _CoreAnyExecuteParams]
= None, execution_options: Optional[ OrmExecuteOptionsParameter]
= None, bind_arguments: Optional[ _BindArguments]
= None) -> Result[ Any]
:
(source)
¶
Execute the statement represented by this :class:`.ORMExecuteState`, without re-invoking events that have already proceeded. This method essentially performs a re-entrant execution of the current statement for which the :meth:`.SessionEvents.do_orm_execute` event is being currently invoked. The use case for this is for event handlers that want to override how the ultimate :class:`_engine.Result` object is returned, such as for schemes that retrieve results from an offline cache or which concatenate results from multiple executions. When the :class:`_engine.Result` object is returned by the actual handler function within :meth:`_orm.SessionEvents.do_orm_execute` and is propagated to the calling :meth:`_orm.Session.execute` method, the remainder of the :meth:`_orm.Session.execute` method is preempted and the :class:`_engine.Result` object is returned to the caller of :meth:`_orm.Session.execute` immediately. :param statement: optional statement to be invoked, in place of the statement currently represented by :attr:`.ORMExecuteState.statement`. :param params: optional dictionary of parameters or list of parameters which will be merged into the existing :attr:`.ORMExecuteState.parameters` of this :class:`.ORMExecuteState`. .. versionchanged:: 2.0 a list of parameter dictionaries is accepted for executemany executions. :param execution_options: optional dictionary of execution options will be merged into the existing :attr:`.ORMExecuteState.execution_options` of this :class:`.ORMExecuteState`. :param bind_arguments: optional dictionary of bind_arguments which will be merged amongst the current :attr:`.ORMExecuteState.bind_arguments` of this :class:`.ORMExecuteState`. :return: a :class:`_engine.Result` object with ORM-level results. .. seealso:: :ref:`do_orm_execute_re_executing` - background and examples on the appropriate usage of :meth:`_orm.ORMExecuteState.invoke_statement`.
The dictionary passed as the :paramref:`_orm.Session.execute.bind_arguments` dictionary. This dictionary may be used by extensions to :class:`_orm.Session` to pass arguments that will assist in determining amongst a set of database connections which one should be used to invoke this statement.
The complete dictionary of current execution options. This is a merge of the statement level options with the locally passed execution options. .. seealso:: :attr:`_orm.ORMExecuteState.local_execution_options` :meth:`_sql.Executable.execution_options` :ref:`orm_queryguide_execution_options`
Dictionary view of the execution options passed to the :meth:`.Session.execute` method. This does not include options that may be associated with the statement being invoked. .. seealso:: :attr:`_orm.ORMExecuteState.execution_options`
The SQL statement being invoked. For an ORM selection as would be retrieved from :class:`_orm.Query`, this is an instance of :class:`_sql.select` that was generated from the ORM query.
Return a sequence of all :class:`_orm.Mapper` objects that are involved at the top level of this statement. By "top level" we mean those :class:`_orm.Mapper` objects that would be represented in the result set rows for a :func:`_sql.select` query, or for a :func:`_dml.update` or :func:`_dml.delete` query, the mapper that is the main subject of the UPDATE or DELETE. .. versionadded:: 1.4.0b2 .. seealso:: :attr:`_orm.ORMExecuteState.bind_mapper`
Return the :class:`_orm.Mapper` that is the primary "bind" mapper. For an :class:`_orm.ORMExecuteState` object invoking an ORM statement, that is, the :attr:`_orm.ORMExecuteState.is_orm_statement` attribute is ``True``, this attribute will return the :class:`_orm.Mapper` that is considered to be the "primary" mapper of the statement. The term "bind mapper" refers to the fact that a :class:`_orm.Session` object may be "bound" to multiple :class:`_engine.Engine` objects keyed to mapped classes, and the "bind mapper" determines which of those :class:`_engine.Engine` objects would be selected. For a statement that is invoked against a single mapped class, :attr:`_orm.ORMExecuteState.bind_mapper` is intended to be a reliable way of getting this mapper. .. versionadded:: 1.4.0b2 .. seealso:: :attr:`_orm.ORMExecuteState.all_mappers`
Return True if the operation is refreshing column-oriented attributes on an existing ORM object. This occurs during operations such as :meth:`_orm.Session.refresh`, as well as when an attribute deferred by :func:`_orm.defer` is being loaded, or an attribute that was expired either directly by :meth:`_orm.Session.expire` or via a commit operation is being loaded. Handlers will very likely not want to add any options to queries when such an operation is occurring as the query should be a straight primary key fetch which should not have any additional WHERE criteria, and loader options travelling with the instance will have already been added to the query. .. versionadded:: 1.4.0b2 .. seealso:: :attr:`_orm.ORMExecuteState.is_relationship_load`
return True if the parameters are a multi-element list of dictionaries with more than one dictionary. .. versionadded:: 2.0
return True if the operation is an ORM statement. This indicates that the select(), insert(), update(), or delete() being invoked contains ORM entities as subjects. For a statement that does not have ORM entities and instead refers only to :class:`.Table` metadata, it is invoked as a Core SQL statement and no ORM-level automation takes place.
Return True if this load is loading objects on behalf of a relationship. This means, the loader in effect is either a LazyLoader, SelectInLoader, SubqueryLoader, or similar, and the entire SELECT statement being emitted is on behalf of a relationship load. Handlers will very likely not want to add any options to queries when such an operation is occurring, as loader options are already capable of being propagated to relationship loaders and should be already present. .. seealso:: :attr:`_orm.ORMExecuteState.is_column_load`
An :class:`.InstanceState` that is using this statement execution for a lazy load operation. The primary rationale for this attribute is to support the horizontal sharding extension, where it is available within specific query execution time hooks created by this extension. To that end, the attribute is only intended to be meaningful at **query execution time**, and importantly not any time prior to that, including query compilation time.
load_options:
Union[ context.QueryContext.default_load_options, Type[ context.QueryContext.default_load_options]]
=
(source)
¶
Return the load_options that will be used for this execution.
Return the :class:`.PathRegistry` for the current load path. This object represents the "path" in a query along relationships when a particular object or collection is being loaded.
update_delete_options:
Union[ bulk_persistence.BulkUDCompileState.default_update_options, Type[ bulk_persistence.BulkUDCompileState.default_update_options]]
=
(source)
¶
Return the update_delete_options that will be used for this execution.
The sequence of :class:`.UserDefinedOptions` that have been associated with the statement being invoked.
Optional[ Union[ context.ORMCompileState.default_compile_options, Type[ context.ORMCompileState.default_compile_options]]]
:
(source)
¶
Undocumented