Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/__pycache__/query.cpython-312.pyc
�

���g�����dZddlmZddlmZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'dd l#m(Z(dd!l#m)Z)dd"lm*Z*dd#lm+Z+dd$lm,Z,dd%lm-Z-dd&lm.Z.d'd(lm/Z0d'd)lm1Z1d'd*lm2Z2d'd+lm3Z3d'd,lm4Z4d'dlmZd'd-l5m6Z6d'd.l5m7Z7d'd/l8m9Z9d'd0l8m:Z:d'd1l4m;Z;d'd2l4m<Z<d'd3l4m=Z=d'd4l4m>Z>d'dl4mZ?d'd5l4m@Z@d'd6lAmBZBd'd7lAmCZCd'd8lDmEZEd'd9lFmGZGd'd:lFmHZHd'd;lFmIZId'd<lFmJZJd'd=lFmKZKd'd>lLmMZMd'd?lNmOZOd'd@lPmQZQd'dAlPmRZRd'dBlPmSZSd'dClPmTZTd'dDlPmUZUd'dElPmVZVd'dFlPmWZWd'dGlPmXZXd'dHlYmZZZd'dIlYm[Z[e�r,ddJlm\Z\ddKlm]Z]ddLlm^Z^ddMlm_Z_ddNl`maZaddOlbmcZcddPldmeZeddQldmfZfddRlgmhZhd'dSlimjZjd'dTlkmlZld'dUlkmmZmd'dVlkmnZnd'dWlkmoZod'dXlpmqZqd'dYlpmrZrd'dZlAmsZsd'd[lAmtZtd'd\lAmuZud'd]lAmvZvd'd^lAmwZwd'd_lAmxZxd'd`lAmyZyd'dalAmzZzd'dblAm{Z{d'dclAm|Z|d'ddlAm}Z}d'delAm~Z~d'dflAmZd'dglAm�Z�d'dhlAm�Z�d'dilAm�Z�d'djlAm�Z�d'dklAm�Z�d'dllAm�Z�d'dmlAm�Z�d'dnlFm�Z�d'dolFm�Z�d'dpl�m�Z�d'dqlLm�Z�d'drlLm�Z�d'dslPm�Z�d'dtlPm�Z�d'dulPm�Z�d'dvlPm�Z�d'dwlPm�Z�d'dxlPm�Z�d'dylPm�Z�d'dzlPm�Z�d'd{lPm�Z�d|d}gZ�ed~e��Z�e2�j2e3�j4Gd��d|eReEeUeVeTe:e3�j6eKeJee����Z�Gd��d�e�j:�Z�Gd��d��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e�e7eC�Z�y)�aThe Query class and support.

Defines the :class:`_query.Query` class, the central
construct used by the ORM to construct database queries.

The :class:`_query.Query` class should not be confused with the
:class:`_expression.Select` class, which defines database
SELECT operations at the SQL (non-ORM) level.  ``Query`` differs from
``Select`` in that it returns ORM-mapped objects and interacts with an
ORM session, whereas the ``Select`` construct interacts directly with the
database to return iterable result sets.

�)�annotationsN)�Any)�Callable)�cast)�Dict)�Generic)�Iterable)�Iterator)�List)�Mapping)�Optional)�overload)�Sequence)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�
attributes)�
interfaces)�loading)�util)�_O)�_assertions��_column_descriptions)�_determine_last_joined_entity)�_legacy_filter_by_entity_zero)�
FromStatement)�ORMCompileState)�QueryContext)�ORMColumnDescription)�ORMColumnsClauseRole)�AliasedClass)�
object_mapper)�with_parent�)�exc)�inspect)�
inspection)�log)�sql)�Result)�Row)�
dispatcher)�EventTarget)�	coercions)�
expression)�roles)�Select)�visitors)�_FromClauseArgument)�_TP)�SupportsCloneAnnotations)�_entity_namespace_key)�_generative)�_NoArg)�
Executable)�
Generative)�BooleanClauseList)�Exists)�_MemoizedSelectEntities)�_SelectFromElements)�ForUpdateArg)�HasHints)�HasPrefixes)�HasSuffixes)�LABEL_STYLE_TABLENAME_PLUS_COL)�SelectLabelStyle)�Literal)�Self)�_EntityType)�_ExternalEntityType)�_InternalEntityType)�SynchronizeSessionArgument)�Mapper)�PathRegistry)�_PKIdentityArgument)�Session)�
InstanceState)�CursorResult)�_ImmutableExecuteOptions)�CompiledCacheType)�IsolationLevel)�SchemaTranslateMapType)�FrozenResult)�ScalarResult)�_ColumnExpressionArgument)�#_ColumnExpressionOrStrLabelArgument)�_ColumnsClauseArgument)�_DMLColumnArgument)�_JoinTargetArgument)�_LimitOffsetType)�
_MAYBE_ENTITY)�_no_kw)�_NOT_ENTITY)�_OnClauseArgument)�_PropagateAttrsType)�_T0)�_T1)�_T2)�_T3)�_T4)�_T5)�_T6)�_T7)�_TypedColumnClauseArgument)�CacheableOptions)�ExecutableOption)�
UpdateBase)�
ColumnElement)�Label)�_ForUpdateOfArgument)�_JoinTargetElement)�_SetupJoinsElement)�Alias)�CTE)�ExecutableReturnsRows)�
FromClause)�ScalarSelect)�Subquery�Queryr"�_T)�boundc���eZdZUdZdZded<dZded<dZded<dZded<dZ	d	ed
<dZ
d	ed<dZd
ed<dZded<dZ
ded<dZded<dZd
ed<dZded<dZded<ej&Zded<dZej.Zded<ded<ej4ddizZej:Zd ed!<dZdZ d"ed#<d$ed%<d&ed'<ejBd�d(��Z"	d�			d�d)�Z#d�d*�Z$				d�d+�Z%d�d,�Z&d�d-�Z'd�d.�Z(						d�d/�Z)e*d�d0��Z+d�d1�Z,d�d2�Z-	d�							d�d3�Z.	d�							d�d4�Z/d�d5�Z0d�d6�Z1d�d7�Z2e3d�d8��Z4					d�											d�d9�Z5d�d:�Z6d�d;�Z7e3d�d<��Z8d�d�d=�Z9	d�					d�d>�Z:			d�							d�d?�Z;			d�							d�d@�Z<d�dA�Z=e>				d�dB��Z?e>				d�dC��Z?e>d�dD��Z?ej�dEdF�d�dG��Z?e>				d�dH��ZAe>				d�dI��ZAe>d�dJ��ZAd�dK�ZAe3d�dL��ZB		d�dM�ZCe>						d�dN��ZDe>						d�dO��ZDe*d�dP��ZDe3d�dQ��ZEe*d�dR��ZFe*d�dS��ZGej�dTdU�V�d�dW��ZIeIZJe3d�dX��ZKd�dY�ZLe*d�dZ��ZMe3d�d[��ZNe*d�d\��ZOe*d�d]��ZPej�d^d_�V�d�d`��ZQ	d�							d�da�ZRe3d�db��ZSe3d�dc��ZTe*				d�dd��ZUe*d�de��ZVe*d�df��ZWe*d�dg��ZXej�dhdi�V�ej�dj�		d�							d�dk���ZZe*	d�					d�dl��Z[e*d�dm��Z\				d�dn�Z]e*d�do��Z^e*	d�					d�dp��Z_ej�dEdq�d�dr��Z`e`Za				d�ds�Zbej�dEdt�d�du��Zce>d�dv��Zde>				d�dw��Zde>						d�dx��Zde>								d�dy��Zde>										d�dz��Zde>												�dd{��Zde>														�dd|��Zde>																�dd}��Zde>																		�dd~��Zde>				�dd��Zde*						�dd���Zde*				�dd���Zeej�dEd���dd���Zfe*�dd���Zg				�dd��Zh�d	d��Zie>d�d�d�ddd�d�d�d�dddd��																											�d
d���Zje>d�d���Zje*�dd���Zje*dddddd��											�dd���Zke*	d�					�d
d���Zl�dd��Zme*ene1e2��dd����ZoejB		�dd���Zp�dd��Zq�dd��Zre*esj�f					�dd���Zue*esj�f					�dd���Zve*ene1e2��dd����Zw�dd��Zx�dd��Zy�dd��Zz�dd��Z{�dd��Z|�dd��Z}�dd��Z~e*ene1e2�	d�ddd��									�dd����Z	d�dd��							�dd��Z�e*ene1�d�d����Z�e*ene0��dd����Z��dd��Z�e*ene1�						�dd����Z�e*ene1��dd����Z�e*ene1��dd����Z�e*ene1��dd����Z��dd��Z�e*ene0��dd����Z��dd��Z��dd��Z��d d��Z��dd��Z��d!d��Z��d"d��Z��d#d��Z��d$d��Z�e3�d%d���Z�ej�d�d��	d�					�d&d���Z�ej�d�d�d���	d�					�d'd���Z��d(d��Z��d)d��Z�		�d*					�d+d��Z�		�d*							�d,d��Z�	�d-					�d.d��Z��d-�d/d��Z�y(0r}aOORM-level SQL construction object.

    .. legacy:: The ORM :class:`.Query` object is a legacy construct
       as of SQLAlchemy 2.0.   See the notes at the top of
       :ref:`query_api_toplevel` for an overview, including links to migration
       documentation.

    :class:`_query.Query` objects are normally initially generated using the
    :meth:`~.Session.query` method of :class:`.Session`, and in
    less common cases by instantiating the :class:`_query.Query` directly and
    associating with a :class:`.Session` using the
    :meth:`_query.Query.with_session`
    method.

    �zTuple[ColumnElement[Any], ...]�_where_criteria�_having_criteria�_order_by_clauses�_group_by_clausesNzOptional[ColumnElement[Any]]�
_limit_clause�_offset_clauseF�bool�	_distinct�_distinct_onzOptional[ForUpdateArg]�_for_update_argzTuple[FromClause, ...]�
_correlateT�_auto_correlate�	_from_objzTuple[_SetupJoinsElement, ...]�_setup_joinsrH�_label_stylez/Union[Type[CacheableOptions], CacheableOptions]�_compile_optionszTuple[ExecutableOption, ...]�
_with_options�_legacy_uniquingzutil.immutabledict[str, Any]�_paramszOptional[ExecutableReturnsRows]�
_statementrR�sessionzdispatcher[Query[_T]]�dispatchc�"�tjS�N)r�
EMPTY_DICT��selfs �E/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/query.py�_propagate_attrszQuery._propagate_attrs�s������c�4�||_|j|�y)a�Construct a :class:`_query.Query` directly.

        E.g.::

            q = Query([User, Address], session=some_session)

        The above is equivalent to::

            q = some_session.query(User, Address)

        :param entities: a sequence of entities and/or SQL expressions.

        :param session: a :class:`.Session` with which the
         :class:`_query.Query`
         will be associated.   Optional; a :class:`_query.Query`
         can be associated
         with a :class:`.Session` generatively via the
         :meth:`_query.Query.with_session` method as well.

        .. seealso::

            :meth:`.Session.query`

            :meth:`_query.Query.with_session`

        N)r��
_set_entities)r��entitiesr�s   r��__init__zQuery.__init__�s��N������8�$r�c�:�tj|�|_|Sr�)r�
immutabledictr�)r��valuess  r��_set_propagate_attrszQuery._set_propagate_attrss�� $� 2� 2�6� :����r�c	��tj|�D�cgc])}tjtj
||d����+c}|_ycc}w)NT��apply_propagate_attrs�post_inspect)r�to_listr2�expectr4�ColumnsClauseRole�_raw_columns)r�r��ents   r�r�zQuery._set_entitiessS���|�|�H�-�
�.��

����'�'��&*�!�	
�.�
����
s�.Ac�$�|jd�S)a�return a tuple-typed form of this :class:`.Query`.

        This method invokes the :meth:`.Query.only_return_tuples`
        method with a value of ``True``, which by itself ensures that this
        :class:`.Query` will always return :class:`.Row` objects, even
        if the query is made against a single entity.  It then also
        at the typing level will return a "typed" query, if possible,
        that will type result rows as ``Tuple`` objects with typed
        elements.

        This method can be compared to the :meth:`.Result.tuples` method,
        which returns "self", but from a typing perspective returns an object
        that will yield typed ``Tuple`` objects for results.   Typing
        takes effect only if this :class:`.Query` object is a typed
        query object already.

        .. versionadded:: 2.0

        .. seealso::

            :meth:`.Result.tuples` - v2 equivalent method.

        T)�only_return_tuplesr�s r��tupleszQuery.tuples*s��0�&�&�t�,�,r�c�"�|jsy|jd}d|jvr|jdSd|jvr|jdStj|�D]!}d|jvs�|jdcSy)Nr�parententity�bundle)r��_annotationsr6�iterate)r�r��elements   r��_entity_from_pre_ent_zerozQuery._entity_from_pre_ent_zeroDs���� � ������"���S�-�-�-��#�#�N�3�3�
��)�)�
)��#�#�H�-�-�$�+�+�C�0��!�W�%9�%9�9�"�/�/��?�?�1�r�c��t|j�dk7s4d|jdjvs|jdjst	j
d|z��|jdjdS)Nrr�rz4%s() can only be used against a single mapped class.)�lenr�r��
is_selectable�sa_exc�InvalidRequestError)r��methnames  r��_only_full_mapper_zerozQuery._only_full_mapper_zeroVs�����!�!�"�a�'��T�%6�%6�q�%9�%F�%F�F��$�$�Q�'�5�5��,�,�)�+3�4��
�
� � ��#�0�0��@�@r�c	���|D�cgc])}tjtj|d|����+}}|xjd|iz
c_t|�|_ycc}w)NT)�allow_selectr��_set_base_alias)r2r�r4�StrictFromClauseRoler��tupler�)r��obj�set_base_alias�elem�fas     r��_set_select_fromzQuery._set_select_fromcsn���
���

����*�*��!�&*�	
��	�
�	
���"3�^�!D�D���r�����
s�.Ac�4�|xjd|iz
c_|S)N�_lazy_loaded_from��load_options)r��states  r��_set_lazyload_fromzQuery._set_lazyload_fromss�����1�5�9�9���r�c�,�|jddd��y)zused by legacy BakedQuery�getF��order_by�distinctN)�_no_criterion_conditionr�s r��_get_conditionzQuery._get_conditionxs���$�$�U�U�U�$�Kr�c�,�|jddd��y)Nr�Fr�)�_no_criterion_assertionr�s r��_get_existing_conditionzQuery._get_existing_condition|s���$�$�U�U�U�$�Kr�c�0�|jsy|jsd|j�X|jsL|js@|j
�4|j�(|js|r|js|r%|jrtjd|z��yy�Nz<Query.%s() being called on a Query with existing criterion. )�_enable_assertionsr�r�r�r�r�r�r�r�r�r�r��r��methr�r�s    r�r�zQuery._no_criterion_assertions����&�&��� � ����*��~�~�� � ��!�!�-��"�"�.��%�%��T�3�3��T�^�^��,�,�2�48�9��
�,�r�c���|j|||�dx|_|_|j�|xjddiz
c_d|_d|_dx|_|_y)Nr�r�F)	r�r�r�r�r�r�r�r�r�r�s    r�r�zQuery._no_criterion_condition�sd��	
�$�$�T�8�X�>�-/�/����*��?�?�&��!�!�l�D�%9�9�!�!������:<�<����!7r�c��|jsy|jrtjd|z��|j	|�yr�)r�r�r�r�r��r�r�s  r��_no_clauseelement_conditionz!Query._no_clauseelement_condition�sG���&�&���!�!��,�,�2�48�9��
�	
�$�$�T�*r�c�f�|jsy|j�tjd|z��y)Nz[Query.%s() being called on a Query with an existing full statement - can't apply criterion.)r�r�r�r�r�s  r��_no_statement_conditionzQuery._no_statement_condition�s?���&�&���?�?�&��,�,�9��	��
�'r�c��|jsy|j�|j�tjd|�d|�d���y)NzQuery.zL() being called on a Query which already has LIMIT or OFFSET applied.  Call z*() before limit() or offset() are applied.)r�r�r�r�r�r�s  r��_no_limit_offsetzQuery._no_limit_offset�sJ���&�&�����)�T�-@�-@�-L��,�,�#'��.��
�.Mr�c�>�|jduxs|jduSr�)r�r�r�s r��_has_row_limiting_clausezQuery._has_row_limiting_clause�s'��
���d�*�M�d�.A�.A��.M�	
r�c���i}i}|r||d<|r||d<|r
||d<d|d<|rt|�|d<|r||d<|r|xj|z
c_|r|xj|z
c_|S)N�_version_check�_populate_existing�_refresh_stateT�_for_refresh_state�_only_load_props�_identity_token)�	frozensetr�r�)r��populate_existing�
version_check�only_load_props�
refresh_state�identity_tokenr��compile_optionss        r��_get_optionszQuery._get_options�s���(*��*,���-:�L�)�*��1B�L�-�.��-:�L�)�*�48�O�0�1��2;�O�2L�O�.�/��.<�L�*�+������-����!�!�_�4�!��r�c�"�|j�Sr�)�	_generate)r��kws  r��_clonezQuery._clone�s���~�~��r�c�p�|j�tjd��td|j�S)Nz<Can't call this method on a Query that uses from_statement()�
Select[_T])r�r�r�r�	statementr�s r��_get_select_statement_onlyz Query._get_select_statement_only�s5���?�?�&��,�,�N��
��L�$�.�.�1�1r�c���|jjs|jd��}n|jd��j}|j
r|j
|j
�}|S)z�The full SELECT statement represented by this Query.

        The statement by default will not have disambiguating labels
        applied to the construct unless with_labels(True) is called
        first.

        T��
for_statement)r�r��
_statement_20�_compile_staterr��params)r��stmts  r�rzQuery.statement�s_��>�$�$�4�4��%�%�D�%�9�D��&�&�T�&�:�D�D�D��<�<��;�;�t�|�|�,�D��r�c�Z�|j�}|j|��jS)a8Return the 'final' SELECT statement for this :class:`.Query`.

        This is used by the testing suite only and is fairly inefficient.

        This is the Core-only select() that will be rendered by a complete
        compilation of this query, and is what .statement used to return
        in 1.3.


        )�use_legacy_query_style)r�rr)r��legacy_query_style�qs   r��_final_statementzQuery._final_statements/��
�K�K�M�����#5� �
�
�)�	r�c�"�|jjrQ|jjD]8}||�}|��||us�|}|jr�"|xjddiz
c_�:|j}|||d�z
}|j�it|j|j�}|jj|j|j||j|j��nmtjd
i|j��}|jj|j||j��|jj!dd�d|jvr#|jj#ddd	��|_|S)N�_bake_okF)�_for_statement�_use_legacy_query_style)r��_with_context_optionsr��_execution_optionsr�)r�r�r�r��compile_state_plugin�orm)r�plugin_subjectr�)r��before_compilerr�r�r r��__dict__�updater�rrr�r5�_create_raw_selectr��pop�union)r�rr
�fn�	new_queryr�rs       r�rzQuery._statement_20,sr���=�=�'�'��m�m�2�2���t�H�	��(�Y�d�-B�$�D��;�;��-�-�*�e�1D�D�-�3��/�/���+�'=�
�	
���?�?�&� ��!2�!2�D�O�O�D�D��M�M� � �"�0�0�&*�&@�&@�!0�#'�#:�#:�!%�!6�!6�
!�
��,�,�=�t�}�}�=�D��M�M� � �!�.�.�!0�!%�!6�!6�
!�
�

�M�M���i��.�"��)>�)>�>�$(�$9�$9�$?�$?�).�$�G�%�D�!��r�c���|jd�}|r|jt�}|j�}trt|t�sJ�|r|j�}|j|��S)a�Return the full SELECT statement represented by
        this :class:`_query.Query`, embedded within an
        :class:`_expression.Alias`.

        Eager JOIN generation within the query is disabled.

        .. seealso::

            :meth:`_sql.Select.subquery` - v2 comparable method.

        :param name: string name to be assigned as the alias;
            this is passed through to :meth:`_expression.FromClause.alias`.
            If ``None``, a name will be deterministically generated
            at compile time.

        :param with_labels: if True, :meth:`.with_labels` will be called
         on the :class:`_query.Query` first to apply table-qualified labels
         to all columns.

        :param reduce_columns: if True,
         :meth:`_expression.Select.reduce_columns` will
         be called on the resulting :func:`_expression.select` construct,
         to remove same-named columns where one also refers to the other
         via foreign key or WHERE clause equivalence.

        F)�name)	�enable_eagerloads�set_label_stylerGrr�
isinstancer5�reduce_columns�subquery)r�r �with_labelsr$rrs      r�r%zQuery.subquery`sl��@
�"�"�5�)����!�!�"@�A�A��+�+�-����d�F�+�+�+���&�&�(�D��}�}�$�}�'�'r�c�d�|jd�j�j|||��S)a�Return the full SELECT statement represented by this
        :class:`_query.Query` represented as a common table expression (CTE).

        Parameters and usage are the same as those of the
        :meth:`_expression.SelectBase.cte` method; see that method for
        further details.

        Here is the `PostgreSQL WITH
        RECURSIVE example
        <https://www.postgresql.org/docs/current/static/queries-with.html>`_.
        Note that, in this example, the ``included_parts`` cte and the
        ``incl_alias`` alias of it are Core selectables, which
        means the columns are accessed via the ``.c.`` attribute.  The
        ``parts_alias`` object is an :func:`_orm.aliased` instance of the
        ``Part`` entity, so column-mapped attributes are available
        directly::

            from sqlalchemy.orm import aliased


            class Part(Base):
                __tablename__ = "part"
                part = Column(String, primary_key=True)
                sub_part = Column(String, primary_key=True)
                quantity = Column(Integer)


            included_parts = (
                session.query(Part.sub_part, Part.part, Part.quantity)
                .filter(Part.part == "our part")
                .cte(name="included_parts", recursive=True)
            )

            incl_alias = aliased(included_parts, name="pr")
            parts_alias = aliased(Part, name="p")
            included_parts = included_parts.union_all(
                session.query(
                    parts_alias.sub_part, parts_alias.part, parts_alias.quantity
                ).filter(parts_alias.part == incl_alias.c.sub_part)
            )

            q = session.query(
                included_parts.c.sub_part,
                func.sum(included_parts.c.quantity).label("total_quantity"),
            ).group_by(included_parts.c.sub_part)

        .. seealso::

            :meth:`_sql.Select.cte` - v2 equivalent method.

        F)r �	recursive�nesting)r!r�cte)r�r r(r)s    r�r*z	Query.cte�s1��t
�"�"�5�)�
'�
'�
)�
�S�d�i��S�
A�	
r�c�^�|jd�j�j|�S)z�Return the full SELECT statement represented by this
        :class:`_query.Query`, converted
        to a scalar subquery with a label of the given name.

        .. seealso::

            :meth:`_sql.Select.label` - v2 comparable method.

        F)r!r�label)r�r s  r�r,zQuery.label�s)��
�"�"�5�)�
'�
'�
)�
�U�4�[�	
r�c��yr�r�r�s r��	as_scalarzQuery.as_scalar�s��'*r�c��yr�r�r�s r�r.zQuery.as_scalar����%(r�c��yr�r�r�s r�r.zQuery.as_scalar�s��.1r��1.4z�The :meth:`_query.Query.as_scalar` method is deprecated and will be removed in a future release.  Please refer to :meth:`_query.Query.scalar_subquery`.c�"�|j�S)z}Return the full SELECT statement represented by this
        :class:`_query.Query`, converted to a scalar subquery.

        )�scalar_subqueryr�s r�r.zQuery.as_scalar�s���#�#�%�%r�c��yr�r�r�s r�r4zQuery.scalar_subquery�s�� r�c��yr�r�r�s r�r4zQuery.scalar_subquery�r0r�c��yr�r�r�s r�r4zQuery.scalar_subquerys��47r�c�\�|jd�j�j�S)a�Return the full SELECT statement represented by this
        :class:`_query.Query`, converted to a scalar subquery.

        Analogous to
        :meth:`sqlalchemy.sql.expression.SelectBase.scalar_subquery`.

        .. versionchanged:: 1.4 The :meth:`_query.Query.scalar_subquery`
           method replaces the :meth:`_query.Query.as_scalar` method.

        .. seealso::

            :meth:`_sql.Select.scalar_subquery` - v2 comparable method.

        F)r!rr4r�s r�r4zQuery.scalar_subquerys(��"
�"�"�5�)�
'�
'�
)�
�_�
�	
r�c�"�|j�S)z�Return the :class:`_expression.Select` object emitted by this
        :class:`_query.Query`.

        Used for :func:`_sa.inspect` compatibility, this is equivalent to::

            query.enable_eagerloads(False).with_labels().statement

        )�__clause_element__r�s r��
selectablezQuery.selectables���&�&�(�(r�c�b�|jdd��jt�jS)NFT)�_enable_eagerloads�_render_for_subquery)�_with_compile_optionsr"rGrr�s r�r:zQuery.__clause_element__&s3��
�&�&�#(�t�
'�
��_�;�
<�
�Y�	
r�c��yr�r��r��values  r�r�zQuery.only_return_tuples1s��(+r�c��yr�r�rAs  r�r�zQuery.only_return_tuples6s��r�c�D�|xjt|��z
c_|S)a�When set to True, the query results will always be a
        :class:`.Row` object.

        This can change a query that normally returns a single entity
        as a scalar to return a :class:`.Row` result in all cases.

        .. seealso::

            :meth:`.Query.tuples` - returns tuples, but also at the typing
            level will type results as ``Tuple``.

            :meth:`_query.Query.is_single_entity`

            :meth:`_engine.Result.tuples` - v2 comparable method.

        )�_only_return_tuples)r��dictrAs  r�r�zQuery.only_return_tuples;s��$	
���T�e�<�<���r�c��|jjxrat|j�dk(xrGd|jdjvxr*t|jdjdt�S)a�Indicates if this :class:`_query.Query`
        returns tuples or single entities.

        Returns True if this query returns a single entity for each instance
        in its result list, and False if this query returns a tuple of entities
        for each result.

        .. versionadded:: 1.3.11

        .. seealso::

            :meth:`_query.Query.only_return_tuples`

        rr�r)r�rEr�r�r�r#r$r�s r��is_single_entityzQuery.is_single_entityPs|��"�!�!�5�5�5�
��D�%�%�&�!�+�
��$�"3�"3�A�"6�"C�"C�C�
���!�!�!�$�1�1�.�A�$��		
r�c�4�|xjd|iz
c_|S)aControl whether or not eager joins and subqueries are
        rendered.

        When set to False, the returned Query will not render
        eager joins regardless of :func:`~sqlalchemy.orm.joinedload`,
        :func:`~sqlalchemy.orm.subqueryload` options
        or mapper-level ``lazy='joined'``/``lazy='subquery'``
        configurations.

        This is used primarily when nesting the Query's
        statement into a subquery or other
        selectable, or when using :meth:`_query.Query.yield_per`.

        r=�r�rAs  r�r!zQuery.enable_eagerloadsjs �� 	
���"6��!>�>���r�c�0�|xj|z
c_|Sr�rJ�r��opts  r�r?zQuery._with_compile_options}s������$���r�zB:meth:`_orm.Query.with_labels` and :meth:`_orm.Query.apply_labels`z<Use set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) instead.)�alternativec�@�|jtj�Sr�)r"rHrGr�s r�r&zQuery.with_labels�s ���#�#��;�;�
�	
r�c��|jS)z�
        Retrieve the current label style.

        .. versionadded:: 1.4

        .. seealso::

            :meth:`_sql.Select.get_label_style` - v2 equivalent method.

        )r�r�s r��get_label_stylezQuery.get_label_style�s��� � � r�c�P�|j|ur|j�}||_|S)a�Apply column labels to the return value of Query.statement.

        Indicates that this Query's `statement` accessor should return
        a SELECT statement that applies labels to all columns in the
        form <tablename>_<columnname>; this is commonly used to
        disambiguate columns from multiple tables which have the same
        name.

        When the `Query` actually issues SQL to load rows, it always
        uses column labeling.

        .. note:: The :meth:`_query.Query.set_label_style` method *only* applies
           the output of :attr:`_query.Query.statement`, and *not* to any of
           the result-row invoking systems of :class:`_query.Query` itself,
           e.g.
           :meth:`_query.Query.first`, :meth:`_query.Query.all`, etc.
           To execute
           a query using :meth:`_query.Query.set_label_style`, invoke the
           :attr:`_query.Query.statement` using :meth:`.Session.execute`::

                result = session.execute(
                    query.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL).statement
                )

        .. versionadded:: 1.4


        .. seealso::

            :meth:`_sql.Select.set_label_style` - v2 equivalent method.

        )r�r�)r��styles  r�r"zQuery.set_label_style�s,��B���E�)��>�>�#�D� %�D���r�c��||_|S)aControl whether assertions are generated.

        When set to False, the returned Query will
        not assert its state before certain operations,
        including that LIMIT/OFFSET has not been applied
        when filter() is called, no criterion exists
        when get() is called, and no "from_statement()"
        exists when filter()/order_by()/group_by() etc.
        is called.  This more permissive mode is used by
        custom Query subclasses to specify criterion or
        other modifiers outside of the usual usage patterns.

        Care should be taken to ensure that the usage
        pattern is even possible.  A statement applied
        by from_statement() will override any criterion
        set by filter() or order_by(), for example.

        )r�rAs  r��enable_assertionszQuery.enable_assertions�s��(#(����r�c�@�tj|j�S)a3A readonly attribute which returns the current WHERE criterion for
        this Query.

        This returned value is a SQL expression construct, or ``None`` if no
        criterion has been established.

        .. seealso::

            :attr:`_sql.Select.whereclause` - v2 equivalent property.

        )r?�_construct_for_whereclauser�r�s r��whereclausezQuery.whereclause�s ��!�;�;�� � �
�	
r�c�4�|xjd|iz
c_|S)aindicate that this query applies to objects loaded
        within a certain path.

        Used by deferred loaders (see strategies.py) which transfer
        query options from an originating query to a newly generated
        query intended for the deferred load.

        �
_current_pathrJ)r��paths  r��_with_current_pathzQuery._with_current_path�s��	
���/�4�!8�8���r�c�4�|xjd|iz
c_|S)a�Yield only ``count`` rows at a time.

        The purpose of this method is when fetching very large result sets
        (> 10K rows), to batch results in sub-collections and yield them
        out partially, so that the Python interpreter doesn't need to declare
        very large areas of memory which is both time consuming and leads
        to excessive memory use.   The performance from fetching hundreds of
        thousands of rows can often double when a suitable yield-per setting
        (e.g. approximately 1000) is used, even with DBAPIs that buffer
        rows (which are most).

        As of SQLAlchemy 1.4, the :meth:`_orm.Query.yield_per` method is
        equivalent to using the ``yield_per`` execution option at the ORM
        level. See the section :ref:`orm_queryguide_yield_per` for further
        background on this option.

        .. seealso::

            :ref:`orm_queryguide_yield_per`

        �
_yield_perr�)r��counts  r��	yield_perzQuery.yield_per�s��.	
���l�E�2�2���r�z:meth:`_orm.Query.get`z7The method is now available as :meth:`_orm.Session.get`c�j�|jddd��|j|tj�S)a�Return an instance based on the given primary key identifier,
        or ``None`` if not found.

        E.g.::

            my_user = session.query(User).get(5)

            some_object = session.query(VersionedFoo).get((5, 10))

            some_object = session.query(VersionedFoo).get({"id": 5, "version_id": 10})

        :meth:`_query.Query.get` is special in that it provides direct
        access to the identity map of the owning :class:`.Session`.
        If the given primary key identifier is present
        in the local identity map, the object is returned
        directly from this collection and no SQL is emitted,
        unless the object has been marked fully expired.
        If not present,
        a SELECT is performed in order to locate the object.

        :meth:`_query.Query.get` also will perform a check if
        the object is present in the identity map and
        marked as expired - a SELECT
        is emitted to refresh the object as well as to
        ensure that the row is still present.
        If not, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised.

        :meth:`_query.Query.get` is only used to return a single
        mapped instance, not multiple instances or
        individual column constructs, and strictly
        on a single primary key value.  The originating
        :class:`_query.Query` must be constructed in this way,
        i.e. against a single mapped entity,
        with no additional filtering criterion.  Loading
        options via :meth:`_query.Query.options` may be applied
        however, and will be used if the object is not
        yet locally present.

        :param ident: A scalar, tuple, or dictionary representing the
         primary key.  For a composite (e.g. multiple column) primary key,
         a tuple or dictionary should be passed.

         For a single-column primary key, the scalar calling form is typically
         the most expedient.  If the primary key of a row is the value "5",
         the call looks like::

            my_object = query.get(5)

         The tuple form contains primary key values typically in
         the order in which they correspond to the mapped
         :class:`_schema.Table`
         object's primary key columns, or if the
         :paramref:`_orm.Mapper.primary_key` configuration parameter were
         used, in
         the order used for that parameter. For example, if the primary key
         of a row is represented by the integer
         digits "5, 10" the call would look like::

             my_object = query.get((5, 10))

         The dictionary form should include as keys the mapped attribute names
         corresponding to each element of the primary key.  If the mapped class
         has the attributes ``id``, ``version_id`` as the attributes which
         store the object's primary key value, the call would look like::

            my_object = query.get({"id": 5, "version_id": 10})

         .. versionadded:: 1.3 the :meth:`_query.Query.get`
            method now optionally
            accepts a dictionary of attribute names to values in order to
            indicate a primary key identifier.


        :return: The object instance, or ``None``.

        r�Fr�)r��	_get_implr�load_on_pk_identity)r��idents  r�r�z	Query.gets3��b	
�$�$�U�U�U�$�K��~�~�e�W�%@�%@�A�Ar�c
���|jd�}|jj||||jj|j
|j||j��S)Nr�)r��with_for_update�optionsr��execution_options)r�r�rbr�r�r�r�r)r��primary_key_identity�
db_load_fnr��mappers     r�rbzQuery._get_implhsf���,�,�U�3���|�|�%�%�� ��"�/�/�B�B� �0�0��&�&�)�"�5�5�&�	
�		
r�c�.�|jjS)a�An :class:`.InstanceState` that is using this :class:`_query.Query`
        for a lazy load operation.

        .. deprecated:: 1.4  This attribute should be viewed via the
           :attr:`.ORMExecuteState.lazy_loaded_from` attribute, within
           the context of the :meth:`.SessionEvents.do_orm_execute`
           event.

        .. seealso::

            :attr:`.ORMExecuteState.lazy_loaded_from`

        )r�r�r�s r��lazy_loaded_fromzQuery.lazy_loaded_fromzs��� � �2�2�2r�c�.�|jjSr�)r�rZr�s r�rZzQuery._current_path�s���$�$�2�2�2r�c��d|_|r|ddvr	d|_|S|jtd�|D��z|_|S)a�Return a :class:`.Query` construct which will correlate the given
        FROM clauses to that of an enclosing :class:`.Query` or
        :func:`~.expression.select`.

        The method here accepts mapped classes, :func:`.aliased` constructs,
        and :class:`_orm.Mapper` constructs as arguments, which are resolved
        into expression constructs, in addition to appropriate expression
        constructs.

        The correlation arguments are ultimately passed to
        :meth:`_expression.Select.correlate`
        after coercion to expression constructs.

        The correlation arguments take effect in such cases
        as when :meth:`_query.Query.from_self` is used, or when
        a subquery as returned by :meth:`_query.Query.subquery` is
        embedded in another :func:`_expression.select` construct.

        .. seealso::

            :meth:`_sql.Select.correlate` - v2 equivalent method.

        Fr>FNr�c3�dK�|](}tjtj|����*y�wr�)r2r�r4�FromClauseRole)�.0�fs  r��	<genexpr>z"Query.correlate.<locals>.<genexpr>�s'����6�CN�a�	� � ��!5�!5�q�9�;���.0)r�r�r�)r��fromclausess  r��	correlatezQuery.correlate�sU��: %����;�q�>�]�:� �D�O�
��#�o�o��6�CN�6�1��D�O��r�c�4�|xjd|iz
c_|S)a?Return a Query with a specific 'autoflush' setting.

        As of SQLAlchemy 1.4, the :meth:`_orm.Query.autoflush` method
        is equivalent to using the ``autoflush`` execution option at the
        ORM level. See the section :ref:`orm_queryguide_autoflush` for
        further background on this option.

        �
_autoflushr�)r��settings  r��	autoflushzQuery.autoflush�s��	
���l�G�4�4���r�c�4�|xjddiz
c_|S)a�Return a :class:`_query.Query`
        that will expire and refresh all instances
        as they are loaded, or reused from the current :class:`.Session`.

        As of SQLAlchemy 1.4, the :meth:`_orm.Query.populate_existing` method
        is equivalent to using the ``populate_existing`` execution option at
        the ORM level. See the section :ref:`orm_queryguide_populate_existing`
        for further background on this option.

        r�Tr�r�s r�r�zQuery.populate_existing�s ��	
���2�D�9�9���r�c�4�|xjd|iz
c_|S)z�Set the 'invoke all eagers' flag which causes joined- and
        subquery loaders to traverse into already-loaded related objects
        and collections.

        Default is that of :attr:`_query.Query._invoke_all_eagers`.

        �_invoke_all_eagersr�rAs  r��_with_invoke_all_eagerszQuery._with_invoke_all_eagers�s ��	
���2�E�:�:���r�z:meth:`_orm.Query.with_parent`z6Use the :func:`_orm.with_parent` standalone construct.zsqlalchemy.orm.relationshipsc���tjj}|rt|�}nt	|�}|��t|�}|jD]5}t||j�s�|j|jus�3|}nOtjd|jjj�d|jj�d���|jt!|||j"��S)aAdd filtering criterion that relates the given instance
        to a child object or collection, using its attribute state
        as well as an established :func:`_orm.relationship()`
        configuration.

        The method uses the :func:`.with_parent` function to generate
        the clause, the result of which is passed to
        :meth:`_query.Query.filter`.

        Parameters are the same as :func:`.with_parent`, with the exception
        that the given property can be None, in which case a search is
        performed against this :class:`_query.Query` object's target mapper.

        :param instance:
          An instance which has some :func:`_orm.relationship`.

        :param property:
          Class bound attribute which indicates
          what relationship from the instance should be used to reconcile the
          parent/child relationship.

        :param from_entity:
          Entity in which to consider as the left side.  This defaults to the
          "zero" entity of the :class:`_query.Query` itself.

        z>Could not locate a property which relates instances of class 'z' to instances of class '�')r�	preloaded�orm_relationshipsr*rr&�iterate_propertiesr#�RelationshipPropertyrkr�r��class_�__name__�	__class__�filterr'�entity)r��instance�property�from_entity�
relationships�entity_zerork�props        r�r'zQuery.with_parent�s���N���8�8�
��!�+�.�K�7��=�K���"�8�,�F��1�1���t�]�%G�%G�H����{�'9�'9�9�#�H��
2��0�0�$�*�*�1�1�:�:� �*�*�3�3�	����{�{�����"�"�
�
�	
r�c���|�t||�}t|j�|_|jjt	j
tj||���|S)z�add a mapped entity to the list of result columns
        to be returned.

        .. seealso::

            :meth:`_sql.Select.add_columns` - v2 comparable method.
        �r�)r%�listr��appendr2r�r4r�)r�r��aliass   r��
add_entityzQuery.add_entity's_����!�&�%�0�F� ��!2�!2�3������ � �����'�'��t�
�	
�
�r�c��||_|S)aReturn a :class:`_query.Query` that will use the given
        :class:`.Session`.

        While the :class:`_query.Query`
        object is normally instantiated using the
        :meth:`.Session.query` method, it is legal to build the
        :class:`_query.Query`
        directly without necessarily using a :class:`.Session`.  Such a
        :class:`_query.Query` object, or any :class:`_query.Query`
        already associated
        with a different :class:`.Session`, can produce a new
        :class:`_query.Query`
        object associated with a target session using this method::

            from sqlalchemy.orm import Query

            query = Query([MyClass]).filter(MyClass.id == 5)

            result = query.with_session(my_session).one()

        )r�)r�r�s  r��with_sessionzQuery.with_sessionBs��0����r�c���|jt�jd�j�j	�}|j|�}|r|j
|�|Sr�)r"rGrwr%�_anonymous_fromclause�_from_selectabler�)r�r��
fromclausers    r��_legacy_from_selfzQuery._legacy_from_self]sW��
� � �!?�@�
�Y�t�_�
�X�Z�
"�
"�
$�		�
�!�!�*�-���
�O�O�H�%��r�c�4�|xjd|iz
c_|S)N�_enable_single_critrJ)r��vals  r��_set_enable_single_critzQuery._set_enable_single_critps�����"7��!=�=���r�c��dD]}|jj|d�� |j|g|�|xjddiz
c_|S)N)
r�r�r�r�r��_last_joined_entityr��_memoized_select_entitiesr�r�r��	_prefixes�	_suffixesr�F)rrr�r�)r�r��set_entity_from�attrs    r�r�zQuery._from_selectableusZ��
�D�
�M�M���d�D�)�
� 	
���z�l�O�<����!�5�"
�	
���r�z�:meth:`_query.Query.values` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.with_entities`c� �|j|�S)zfReturn an iterator yielding result tuples corresponding
        to the given list of columns

        )�_values_no_warn)r��columnss  r�r�zQuery.values�s��$�t�#�#�W�-�-r�c���|std�S|j�jd�}|j|�|jj
s|xjddiz
c_t|�S)Nr�Fr^�
)�iterr�r!r�r�r^)r�r�rs   r�r�zQuery._values_no_warn�s[�����8�O��K�K�M�+�+�E�2��	���� ��~�~�(�(�
�N�N�|�R�0�0�N��A�w�r�z�:meth:`_query.Query.value` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.with_entities` in combination with :meth:`_query.Query.scalar`c�\�	t|j|��dS#t$rYywxYw)zVReturn a scalar result corresponding to the given
        column expression.

        rN)�nextr��
StopIteration�r��columns  r�rBzQuery.value�s4��	���,�,�V�4�5�a�8�8���	��	�s��	+�+c��yr�r�)r��_entitys  r��
with_entitieszQuery.with_entities�s��DGr�c��yr�r�)r��_colexprs  r�r�zQuery.with_entities�s��(+r�c��yr�r�)r��_Query__ent0�_Query__ent1s   r�r�zQuery.with_entities�s��.1r�c��yr�r�)r�r�r��_Query__ent2s    r�r�zQuery.with_entities�s��36r�c��yr�r�)r�r�r�r��_Query__ent3s     r�r�zQuery.with_entities�s��8;r�c��yr�r�)r�r�r�r�r��_Query__ent4s      r�r�zQuery.with_entities�s��=@r�c��yr�r�)r�r�r�r�r�r��_Query__ent5s       r�r�zQuery.with_entities�s	��BEr�c��yr�r�)r�r�r�r�r�r�r��_Query__ent6s        r�r�zQuery.with_entities�s	��GJr�c	��yr�r�)	r�r�r�r�r�r�r�r��_Query__ent7s	         r�r�zQuery.with_entities�s	��LOr�c��yr�r�)r�r�s  r�r�zQuery.with_entitiess��r�c�j�|r
t��tj|�|j|�|S)a�Return a new :class:`_query.Query`
        replacing the SELECT list with the
        given entities.

        e.g.::

            # Users, filtered on some arbitrary criterion
            # and then ordered by related email address
            q = (
                session.query(User)
                .join(User.address)
                .filter(User.name.like("%ed%"))
                .order_by(Address.email)
            )

            # given *only* User.id==5, Address.email, and 'q', what
            # would the *next* User in the result be ?
            subq = (
                q.with_entities(Address.email)
                .order_by(None)
                .filter(User.id == 5)
                .subquery()
            )
            q = q.join((subq, subq.c.email < Address.email)).limit(1)

        .. seealso::

            :meth:`_sql.Select.with_only_columns` - v2 comparable method.
        )rbrA�_generate_for_statementr�)r�r��
_Query__kws   r�r�zQuery.with_entitiess2��B��(�N�
	 �7�7��=����8�$��r�c���t�j��_�jj�fd�|D���S)z�Add one or more column expressions to the list
        of result columns to be returned.

        .. seealso::

            :meth:`_sql.Select.add_columns` - v2 comparable method.
        c3�l�K�|]+}tjtj|�d�����-y�w)Tr�N)r2r�r4r�)rr�cr�s  �r�rtz$Query.add_columns.<locals>.<genexpr>Js?�����!
���

����'�'��&*�!�	
�
��s�14)r�r��extendr�s` r��add_columnszQuery.add_columns<sB���!��!2�!2�3������ � �!
��!
�	
��r�z�:meth:`_query.Query.add_column` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.add_columns`c�$�|j|�S)zWAdd a column expression to the list of result columns to be
        returned.

        )r�r�s  r��
add_columnzQuery.add_columnUs������'�'r�c�b�ttj|��}|jjr3|D]-}|j
r�|js�|j|��/n2|D]-}|j
r�|js�|j|��/|xj|z
c_	|S)aKReturn a new :class:`_query.Query` object,
        applying the given list of
        mapper options.

        Most supplied options regard changing how column- and
        relationship-mapped attributes are loaded.

        .. seealso::

            :ref:`loading_columns`

            :ref:`relationship_loader_options`

        )
r�r�flatten_iteratorr�rZ�_is_core�_is_legacy_option�process_query_conditionally�
process_queryr�)r��args�optsrMs    r�rgz
Query.optionsbs���"�T�*�*�4�0�1��� � �.�.����|�|��(=�(=��3�3�D�9�����|�|��(=�(=��%�%�d�+��	
���d�"���r�c��||�S)a�Return a new :class:`_query.Query` object transformed by
        the given function.

        E.g.::

            def filter_something(criterion):
                def transform(q):
                    return q.filter(criterion)

                return transform


            q = q.with_transformation(filter_something(x == 5))

        This allows ad-hoc recipes to be created for :class:`_query.Query`
        objects.

        r�)r�rs  r��with_transformationzQuery.with_transformation�s
��*�$�x�r�c��|jS)aGet the non-SQL options which will take effect during execution.

        .. versionadded:: 1.3

        .. seealso::

            :meth:`_query.Query.execution_options`

            :meth:`_sql.Select.get_execution_options` - v2 comparable method.

        )rr�s r��get_execution_optionszQuery.get_execution_options�s���&�&�&r�.)�compiled_cache�
logging_token�isolation_level�
no_parameters�stream_results�max_row_bufferr`�insertmanyvalues_page_size�schema_translate_mapr�r{�preserve_rowcountc��yr�r�)r�r�r�r�r�r�r�r`r�r�r�r{r�rMs              r�rhzQuery.execution_options�s��"r�c��yr�r�rLs  r�rhzQuery.execution_options�s��58r�c�F�|jj|�|_|S)a�Set non-SQL options which take effect during execution.

        Options allowed here include all of those accepted by
        :meth:`_engine.Connection.execution_options`, as well as a series
        of ORM specific options:

        ``populate_existing=True`` - equivalent to using
        :meth:`_orm.Query.populate_existing`

        ``autoflush=True|False`` - equivalent to using
        :meth:`_orm.Query.autoflush`

        ``yield_per=<value>`` - equivalent to using
        :meth:`_orm.Query.yield_per`

        Note that the ``stream_results`` execution option is enabled
        automatically if the :meth:`~sqlalchemy.orm.query.Query.yield_per()`
        method or execution option is used.

        .. versionadded:: 1.4 - added ORM options to
           :meth:`_orm.Query.execution_options`

        The execution options may also be specified on a per execution basis
        when using :term:`2.0 style` queries via the
        :paramref:`_orm.Session.execution_options` parameter.

        .. warning:: The
           :paramref:`_engine.Connection.execution_options.stream_results`
           parameter should not be used at the level of individual ORM
           statement executions, as the :class:`_orm.Session` will not track
           objects from different schema translate maps within a single
           session.  For multiple schema translate maps within the scope of a
           single :class:`_orm.Session`, see :ref:`examples_sharding`.


        .. seealso::

            :ref:`engine_stream_results`

            :meth:`_query.Query.get_execution_options`

            :meth:`_sql.Select.execution_options` - v2 equivalent method.

        )rr)r��kwargss  r�rhzQuery.execution_options�s#��\#'�"9�"9�"?�"?��"G����r�)�nowait�read�of�skip_locked�	key_sharec�0�t|||||��|_|S)a,return a new :class:`_query.Query`
        with the specified options for the
        ``FOR UPDATE`` clause.

        The behavior of this method is identical to that of
        :meth:`_expression.GenerativeSelect.with_for_update`.
        When called with no arguments,
        the resulting ``SELECT`` statement will have a ``FOR UPDATE`` clause
        appended.  When additional arguments are specified, backend-specific
        options such as ``FOR UPDATE NOWAIT`` or ``LOCK IN SHARE MODE``
        can take effect.

        E.g.::

            q = (
                sess.query(User)
                .populate_existing()
                .with_for_update(nowait=True, of=User)
            )

        The above query on a PostgreSQL backend will render like:

        .. sourcecode:: sql

            SELECT users.id AS users_id FROM users FOR UPDATE OF users NOWAIT

        .. warning::

            Using ``with_for_update`` in the context of eager loading
            relationships is not officially supported or recommended by
            SQLAlchemy and may not work with certain queries on various
            database backends.  When ``with_for_update`` is successfully used
            with a query that involves :func:`_orm.joinedload`, SQLAlchemy will
            attempt to emit SQL that locks all involved tables.

        .. note::  It is generally a good idea to combine the use of the
           :meth:`_orm.Query.populate_existing` method when using the
           :meth:`_orm.Query.with_for_update` method.   The purpose of
           :meth:`_orm.Query.populate_existing` is to force all the data read
           from the SELECT to be populated into the ORM objects returned,
           even if these objects are already in the :term:`identity map`.

        .. seealso::

            :meth:`_expression.GenerativeSelect.with_for_update`
            - Core level method with
            full argument and behavioral description.

            :meth:`_orm.Query.populate_existing` - overwrites attributes of
            objects already loaded in the identity map.

        )r�r�r�r�r�)rCr�)r�r�r�r�r�r�s      r�rfzQuery.with_for_update�s(��~ ,����#�� 
����r�c�l�|r|j|�|jj|�|_|S)a�Add values for bind parameters which may have been
        specified in filter().

        Parameters may be specified using \**kwargs, or optionally a single
        dictionary as the first positional argument. The reason for both is
        that \**kwargs is convenient, however some parameter dictionaries
        contain unicode keys in which case \**kwargs cannot be used.

        )rr�r)r��_Query__paramsr�s   r�rzQuery.params5s.����I�I�h���|�|�)�)�"�-����r�c� �|j|�S)z�A synonym for :meth:`.Query.filter`.

        .. versionadded:: 1.4

        .. seealso::

            :meth:`_sql.Select.where` - v2 equivalent method.

        )r�)r��	criterions  r��wherezQuery.whereGs���t�{�{�I�&�&r�c��t|�D]>}tjtj||��}|xj
|fz
c_�@|S)aNApply the given filtering criterion to a copy
        of this :class:`_query.Query`, using SQL expressions.

        e.g.::

            session.query(MyClass).filter(MyClass.name == "some name")

        Multiple criteria may be specified as comma separated; the effect
        is that they will be joined together using the :func:`.and_`
        function::

            session.query(MyClass).filter(MyClass.name == "some name", MyClass.id > 5)

        The criterion is any SQL expression object applicable to the
        WHERE clause of a select.   String expressions are coerced
        into SQL expression constructs via the :func:`_expression.text`
        construct.

        .. seealso::

            :meth:`_query.Query.filter_by` - filter on keyword expressions.

            :meth:`_sql.Select.where` - v2 equivalent method.

        r�)r�r2r�r4�WhereHavingRoler�)r�r��crits   r�r�zQuery.filterSsK��8��O�D��#�#��%�%�t�4��D�
� � �T�G�+� �$��r�c�F�|jrt|j�Syr�)r�rr�s r�r�zQuery._last_joined_entityws(�����0��!�!��
�r�c��|jr|j}|�|S|jr%|jjs|jdS|j
dS)z�for the filter_by() method, return the target entity for which
        we will attempt to derive an expression from based on string name.

        r)r�r�r�r�r�r�)r�r�s  r��_filter_by_zerozQuery._filter_by_zero�s\�����"&�":�":��"�.�*�*�8�>�>�$�"7�"7�"G�"G��>�>�!�$�$�� � ��#�#r�c��|j�}|j�D��cgc]\}}t||�|k(��}}}|j|�Scc}}w)aApply the given filtering criterion to a copy
        of this :class:`_query.Query`, using keyword expressions.

        e.g.::

            session.query(MyClass).filter_by(name="some name")

        Multiple criteria may be specified as comma separated; the effect
        is that they will be joined together using the :func:`.and_`
        function::

            session.query(MyClass).filter_by(name="some name", id=5)

        The keyword expressions are extracted from the primary
        entity of the query, or the last entity that was the
        target of a call to :meth:`_query.Query.join`.

        .. seealso::

            :meth:`_query.Query.filter` - filter on SQL expressions.

            :meth:`_sql.Select.filter_by` - v2 comparable method.

        )r��itemsr:r�)r�r�r��keyrB�clausess      r��	filter_byzQuery.filter_by�sb��2�*�*�,��%�l�l�n�
�,�
��U�
"�+�s�3�u�<�,�	�
��t�{�{�G�$�$��	
s�Ac���|j|jfD]
}|d��|s|�|dur	d|_|S|tjur+td�|f|zD��}|xj|z
c_|S)a�Apply one or more ORDER BY criteria to the query and return
        the newly resulting :class:`_query.Query`.

        e.g.::

            q = session.query(Entity).order_by(Entity.id, Entity.name)

        Calling this method multiple times is equivalent to calling it once
        with all the clauses concatenated. All existing ORDER BY criteria may
        be cancelled by passing ``None`` by itself.  New ORDER BY criteria may
        then be added by invoking :meth:`_orm.Query.order_by` again, e.g.::

            # will erase all ORDER BY and ORDER BY new_col alone
            q = q.order_by(None).order_by(new_col)

        .. seealso::

            These sections describe ORDER BY in terms of :term:`2.0 style`
            invocation but apply to :class:`_orm.Query` as well:

            :ref:`tutorial_order_by` - in the :ref:`unified_tutorial`

            :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial`

            :meth:`_sql.Select.order_by` - v2 equivalent method.

        r�Fr�c3�dK�|](}tjtj|����*y�wr�)r2r�r4�OrderByRole�rr�clauses  r�rtz!Query.order_by.<locals>.<genexpr>��+�����2�F�� � ��!2�!2�F�;�2�ru)r�r�r�r<�NO_ARGr��r��
_Query__firstr�	assertionr�s     r�r�zQuery.order_by�s���J�6�6��8M�8M�N�I��j�!�O��G�O�w�%�/?�%'�D�"����F�M�M�
)���&�j�7�2���I�
�"�"�i�/�"��r�c���|j|jfD]
}|d��|s|�|dur	d|_|S|tjur+td�|f|zD��}|xj|z
c_|S)a�Apply one or more GROUP BY criterion to the query and return
        the newly resulting :class:`_query.Query`.

        All existing GROUP BY settings can be suppressed by
        passing ``None`` - this will suppress any GROUP BY configured
        on mappers as well.

        .. seealso::

            These sections describe GROUP BY in terms of :term:`2.0 style`
            invocation but apply to :class:`_orm.Query` as well:

            :ref:`tutorial_group_by_w_aggregates` - in the
            :ref:`unified_tutorial`

            :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial`

            :meth:`_sql.Select.group_by` - v2 equivalent method.

        �group_byFr�c3�dK�|](}tjtj|����*y�wr�)r2r�r4�GroupByRolers  r�rtz!Query.group_by.<locals>.<genexpr>$rru)r�r�r�r<rr�r	s     r�r
zQuery.group_bys���<�6�6��8M�8M�N�I��j�!�O��G�O�w�%�/?�%'�D�"���
�F�M�M�
)���&�j�7�2���I�
�"�"�i�/�"��r�c��|D]<}tjtj|�}|xj|fz
c_�>|S)atApply a HAVING criterion to the query and return the
        newly resulting :class:`_query.Query`.

        :meth:`_query.Query.having` is used in conjunction with
        :meth:`_query.Query.group_by`.

        HAVING criterion makes it possible to use filters on aggregate
        functions like COUNT, SUM, AVG, MAX, and MIN, eg.::

            q = (
                session.query(User.id)
                .join(User.addresses)
                .group_by(User.id)
                .having(func.count(Address.id) > 2)
            )

        .. seealso::

            :meth:`_sql.Select.having` - v2 equivalent method.

        )r2r�r4r�r�)r��havingr��having_criterias    r�rzQuery.having+sF��2 �I�'�.�.��%�%�y��O�
�!�!�o�%7�7�!�	 �
�r�c�R�|f|z}|j||�j��Sr�)r�r%)r��expr_fnr�list_of_queriess    r��_set_opz
Query._set_opKs,���'�A�+���$�$�W��%@�%I�%I�%K�L�Lr�c�D�|jtjg|���S)a%Produce a UNION of this Query against one or more queries.

        e.g.::

            q1 = sess.query(SomeClass).filter(SomeClass.foo == "bar")
            q2 = sess.query(SomeClass).filter(SomeClass.bar == "foo")

            q3 = q1.union(q2)

        The method accepts multiple Query objects so as to control
        the level of nesting.  A series of ``union()`` calls such as::

            x.union(y).union(z).all()

        will nest on each ``union()``, and produces:

        .. sourcecode:: sql

            SELECT * FROM (SELECT * FROM (SELECT * FROM X UNION
                            SELECT * FROM y) UNION SELECT * FROM Z)

        Whereas::

            x.union(y, z).all()

        produces:

        .. sourcecode:: sql

            SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y UNION
                            SELECT * FROM Z)

        Note that many database backends do not allow ORDER BY to
        be rendered on a query called within UNION, EXCEPT, etc.
        To disable all ORDER BY clauses including those configured
        on mappers, issue ``query.order_by(None)`` - the resulting
        :class:`_query.Query` object will not render ORDER BY within
        its SELECT statement.

        .. seealso::

            :meth:`_sql.Select.union` - v2 equivalent method.

        )rr3r�r�rs  r�rzQuery.unionOs!��Z�t�|�|�J�,�,�1�q�1�1r�c�D�|jtjg|���S)aProduce a UNION ALL of this Query against one or more queries.

        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.

        .. seealso::

            :meth:`_sql.Select.union_all` - v2 equivalent method.

        )rr3�	union_allrs  r�rzQuery.union_all~� ���t�|�|�J�0�0�5�1�5�5r�c�D�|jtjg|���S)aProduce an INTERSECT of this Query against one or more queries.

        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.

        .. seealso::

            :meth:`_sql.Select.intersect` - v2 equivalent method.

        )rr3�	intersectrs  r�rzQuery.intersect�rr�c�D�|jtjg|���S)a Produce an INTERSECT ALL of this Query against one or more queries.

        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.

        .. seealso::

            :meth:`_sql.Select.intersect_all` - v2 equivalent method.

        )rr3�
intersect_allrs  r�rzQuery.intersect_all�s ���t�|�|�J�4�4�9�q�9�9r�c�D�|jtjg|���S)aProduce an EXCEPT of this Query against one or more queries.

        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.

        .. seealso::

            :meth:`_sql.Select.except_` - v2 equivalent method.

        )rr3�except_rs  r�r!z
Query.except_�s ���t�|�|�J�.�.�3��3�3r�c�D�|jtjg|���S)aProduce an EXCEPT ALL of this Query against one or more queries.

        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.

        .. seealso::

            :meth:`_sql.Select.except_all` - v2 equivalent method.

        )rr3�
except_allrs  r�r#zQuery.except_all�s ���t�|�|�J�1�1�6�A�6�6r���isouter�fullc��tjtj||d��}|�'tjtj|d��}nd}|xj
||d||d�ffz
c_|jjdd�|S)aCreate a SQL JOIN against this :class:`_query.Query`
        object's criterion
        and apply generatively, returning the newly resulting
        :class:`_query.Query`.

        **Simple Relationship Joins**

        Consider a mapping between two classes ``User`` and ``Address``,
        with a relationship ``User.addresses`` representing a collection
        of ``Address`` objects associated with each ``User``.   The most
        common usage of :meth:`_query.Query.join`
        is to create a JOIN along this
        relationship, using the ``User.addresses`` attribute as an indicator
        for how this should occur::

            q = session.query(User).join(User.addresses)

        Where above, the call to :meth:`_query.Query.join` along
        ``User.addresses`` will result in SQL approximately equivalent to:

        .. sourcecode:: sql

            SELECT user.id, user.name
            FROM user JOIN address ON user.id = address.user_id

        In the above example we refer to ``User.addresses`` as passed to
        :meth:`_query.Query.join` as the "on clause", that is, it indicates
        how the "ON" portion of the JOIN should be constructed.

        To construct a chain of joins, multiple :meth:`_query.Query.join`
        calls may be used.  The relationship-bound attribute implies both
        the left and right side of the join at once::

            q = (
                session.query(User)
                .join(User.orders)
                .join(Order.items)
                .join(Item.keywords)
            )

        .. note:: as seen in the above example, **the order in which each
           call to the join() method occurs is important**.    Query would not,
           for example, know how to join correctly if we were to specify
           ``User``, then ``Item``, then ``Order``, in our chain of joins; in
           such a case, depending on the arguments passed, it may raise an
           error that it doesn't know how to join, or it may produce invalid
           SQL in which case the database will raise an error. In correct
           practice, the
           :meth:`_query.Query.join` method is invoked in such a way that lines
           up with how we would want the JOIN clauses in SQL to be
           rendered, and each call should represent a clear link from what
           precedes it.

        **Joins to a Target Entity or Selectable**

        A second form of :meth:`_query.Query.join` allows any mapped entity or
        core selectable construct as a target.   In this usage,
        :meth:`_query.Query.join` will attempt to create a JOIN along the
        natural foreign key relationship between two entities::

            q = session.query(User).join(Address)

        In the above calling form, :meth:`_query.Query.join` is called upon to
        create the "on clause" automatically for us.  This calling form will
        ultimately raise an error if either there are no foreign keys between
        the two entities, or if there are multiple foreign key linkages between
        the target entity and the entity or entities already present on the
        left side such that creating a join requires more information.  Note
        that when indicating a join to a target without any ON clause, ORM
        configured relationships are not taken into account.

        **Joins to a Target with an ON Clause**

        The third calling form allows both the target entity as well
        as the ON clause to be passed explicitly.    A example that includes
        a SQL expression as the ON clause is as follows::

            q = session.query(User).join(Address, User.id == Address.user_id)

        The above form may also use a relationship-bound attribute as the
        ON clause as well::

            q = session.query(User).join(Address, User.addresses)

        The above syntax can be useful for the case where we wish
        to join to an alias of a particular target entity.  If we wanted
        to join to ``Address`` twice, it could be achieved using two
        aliases set up using the :func:`~sqlalchemy.orm.aliased` function::

            a1 = aliased(Address)
            a2 = aliased(Address)

            q = (
                session.query(User)
                .join(a1, User.addresses)
                .join(a2, User.addresses)
                .filter(a1.email_address == "ed@foo.com")
                .filter(a2.email_address == "ed@bar.com")
            )

        The relationship-bound calling form can also specify a target entity
        using the :meth:`_orm.PropComparator.of_type` method; a query
        equivalent to the one above would be::

            a1 = aliased(Address)
            a2 = aliased(Address)

            q = (
                session.query(User)
                .join(User.addresses.of_type(a1))
                .join(User.addresses.of_type(a2))
                .filter(a1.email_address == "ed@foo.com")
                .filter(a2.email_address == "ed@bar.com")
            )

        **Augmenting Built-in ON Clauses**

        As a substitute for providing a full custom ON condition for an
        existing relationship, the :meth:`_orm.PropComparator.and_` function
        may be applied to a relationship attribute to augment additional
        criteria into the ON clause; the additional criteria will be combined
        with the default criteria using AND::

            q = session.query(User).join(
                User.addresses.and_(Address.email_address != "foo@bar.com")
            )

        .. versionadded:: 1.4

        **Joining to Tables and Subqueries**


        The target of a join may also be any table or SELECT statement,
        which may be related to a target entity or not.   Use the
        appropriate ``.subquery()`` method in order to make a subquery
        out of a query::

            subq = (
                session.query(Address)
                .filter(Address.email_address == "ed@foo.com")
                .subquery()
            )


            q = session.query(User).join(subq, User.id == subq.c.user_id)

        Joining to a subquery in terms of a specific relationship and/or
        target entity may be achieved by linking the subquery to the
        entity using :func:`_orm.aliased`::

            subq = (
                session.query(Address)
                .filter(Address.email_address == "ed@foo.com")
                .subquery()
            )

            address_subq = aliased(Address, subq)

            q = session.query(User).join(User.addresses.of_type(address_subq))

        **Controlling what to Join From**

        In cases where the left side of the current state of
        :class:`_query.Query` is not in line with what we want to join from,
        the :meth:`_query.Query.select_from` method may be used::

            q = (
                session.query(Address)
                .select_from(User)
                .join(User.addresses)
                .filter(User.name == "ed")
            )

        Which will produce SQL similar to:

        .. sourcecode:: sql

            SELECT address.* FROM user
                JOIN address ON user.id=address.user_id
                WHERE user.name = :name_1

        .. seealso::

            :meth:`_sql.Select.join` - v2 equivalent method.

        :param \*props: Incoming arguments for :meth:`_query.Query.join`,
         the props collection in modern use should be considered to be a  one
         or two argument form, either as a single "target" entity or ORM
         attribute-bound relationship, or as a target entity plus an "on
         clause" which  may be a SQL expression or ORM attribute-bound
         relationship.

        :param isouter=False: If True, the join used will be a left outer join,
         just as if the :meth:`_query.Query.outerjoin` method were called.

        :param full=False: render FULL OUTER JOIN; implies ``isouter``.

        T)r��legacyN�r(r$r�)r2r�r4�JoinTargetRole�OnClauseRoler�rr)r��target�onclauser%r&�join_target�onclause_elements       r��joinz
Query.join�s���b �&�&�� � ��"&��	
����(�/�/��"�"�H�T� �� $������ ��&� ��	
�

�
	
��	
�
�
���/��6��r�)r&c�,�|j||d|��S)a#Create a left outer join against this ``Query`` object's criterion
        and apply generatively, returning the newly resulting ``Query``.

        Usage is the same as the ``join()`` method.

        .. seealso::

            :meth:`_sql.Select.outerjoin` - v2 equivalent method.

        T)r-r%r&)r0)r�r,r-r&s    r��	outerjoinzQuery.outerjoin�	s��"�y�y��(�D�t�y�L�Lr�c��d|_|S)aSReturn a new :class:`.Query`, where the "join point" has
        been reset back to the base FROM entities of the query.

        This method is usually used in conjunction with the
        ``aliased=True`` feature of the :meth:`~.Query.join`
        method.  See the example in :meth:`~.Query.join` for how
        this is used.

        N)r�r�s r��reset_joinpointzQuery.reset_joinpoint�	s��$(�� ��r�c�*�|j|d�|S)a�Set the FROM clause of this :class:`.Query` explicitly.

        :meth:`.Query.select_from` is often used in conjunction with
        :meth:`.Query.join` in order to control which entity is selected
        from on the "left" side of the join.

        The entity or selectable object here effectively replaces the
        "left edge" of any calls to :meth:`~.Query.join`, when no
        joinpoint is otherwise established - usually, the default "join
        point" is the leftmost entity in the :class:`~.Query` object's
        list of entities to be selected.

        A typical example::

            q = (
                session.query(Address)
                .select_from(User)
                .join(User.addresses)
                .filter(User.name == "ed")
            )

        Which produces SQL equivalent to:

        .. sourcecode:: sql

            SELECT address.* FROM user
            JOIN address ON user.id=address.user_id
            WHERE user.name = :name_1

        :param \*from_obj: collection of one or more entities to apply
         to the FROM clause.  Entities can be mapped classes,
         :class:`.AliasedClass` objects, :class:`.Mapper` objects
         as well as core :class:`.FromClause` elements like subqueries.

        .. seealso::

            :meth:`~.Query.join`

            :meth:`.Query.select_entity_from`

            :meth:`_sql.Select.select_from` - v2 equivalent method.

        F)r�)r��from_objs  r��select_fromzQuery.select_from�	s��^	
���h��.��r�c�.�tj||�Sr�)�orm_util�_getitem)r��items  r��__getitem__zQuery.__getitem__
s��� � ���
�	
r�c�x�tj|j|j||�\|_|_|S)aLComputes the "slice" of the :class:`_query.Query` represented by
        the given indices and returns the resulting :class:`_query.Query`.

        The start and stop indices behave like the argument to Python's
        built-in :func:`range` function. This method provides an
        alternative to using ``LIMIT``/``OFFSET`` to get a slice of the
        query.

        For example, ::

            session.query(User).order_by(User.id).slice(1, 3)

        renders as

        .. sourcecode:: sql

           SELECT users.id AS users_id,
                  users.name AS users_name
           FROM users ORDER BY users.id
           LIMIT ? OFFSET ?
           (2, 1)

        .. seealso::

           :meth:`_query.Query.limit`

           :meth:`_query.Query.offset`

           :meth:`_sql.Select.slice` - v2 equivalent method.

        )�sql_util�_make_slicer�r�)r��start�stops   r��slicezQuery.slice
s<��N3;�2F�2F����� 3� 3�U�D�3
�/���D�/��r�c�:�tj|�|_|S)z�Apply a ``LIMIT`` to the query and return the newly resulting
        ``Query``.

        .. seealso::

            :meth:`_sql.Select.limit` - v2 equivalent method.

        )r>�_offset_or_limit_clauser�)r��limits  r�rEzQuery.limit3
s��&�=�=�e�D����r�c�:�tj|�|_|S)z�Apply an ``OFFSET`` to the query and return the newly resulting
        ``Query``.

        .. seealso::

            :meth:`_sql.Select.offset` - v2 equivalent method.
        )r>rDr�)r��offsets  r�rGzQuery.offsetA
s��'�>�>�v�F����r�c�r�|r-d|_|jtd�|D��z|_|Sd|_|S)aUApply a ``DISTINCT`` to the query and return the newly resulting
        ``Query``.


        .. note::

            The ORM-level :meth:`.distinct` call includes logic that will
            automatically add columns from the ORDER BY of the query to the
            columns clause of the SELECT statement, to satisfy the common need
            of the database backend that ORDER BY columns be part of the SELECT
            list when DISTINCT is used.   These columns *are not* added to the
            list of columns actually fetched by the :class:`_query.Query`,
            however,
            so would not affect results. The columns are passed through when
            using the :attr:`_query.Query.statement` accessor, however.

            .. deprecated:: 2.0  This logic is deprecated and will be removed
               in SQLAlchemy 2.0.     See :ref:`migration_20_query_distinct`
               for a description of this use case in 2.0.

        .. seealso::

            :meth:`_sql.Select.distinct` - v2 equivalent method.

        :param \*expr: optional column expressions.  When present,
         the PostgreSQL dialect will render a ``DISTINCT ON (<expressions>)``
         construct.

         .. deprecated:: 1.4 Using \*expr in other dialects is deprecated
            and will raise :class:`_exc.CompileError` in a future version.

        Tc3�dK�|](}tjtj|����*y�wr�)r2r�r4�ByOfRole)rr�es  r�rtz!Query.distinct.<locals>.<genexpr>s
s%����:�=A��	� � �����3�T�ru)r�r�r�)r��exprs  r�r�zQuery.distinctN
sK��F�!�D�N� $� 1� 1�E�:�=A�:�5�!�D��
��"�D�N��r�c�>�|j�j�S)a�Return the results represented by this :class:`_query.Query`
        as a list.

        This results in an execution of the underlying SQL statement.

        .. warning::  The :class:`_query.Query` object,
           when asked to return either
           a sequence or iterator that consists of full ORM-mapped entities,
           will **deduplicate entries based on primary key**.  See the FAQ for
           more details.

            .. seealso::

                :ref:`faq_query_deduplicating`

        .. seealso::

            :meth:`_engine.Result.all` - v2 comparable method.

            :meth:`_engine.Result.scalars` - v2 comparable method.
        )�_iter�allr�s r�rOz	Query.allz
���,�z�z�|���!�!r�c�`�tjtj||��}||_|S)aExecute the given SELECT statement and return results.

        This method bypasses all internal statement compilation, and the
        statement is executed without modification.

        The statement is typically either a :func:`_expression.text`
        or :func:`_expression.select` construct, and should return the set
        of columns
        appropriate to the entity class represented by this
        :class:`_query.Query`.

        .. seealso::

            :meth:`_sql.Select.from_statement` - v2 comparable method.

        r�)r2r�r4�SelectStatementRoler�)r�rs  r��from_statementzQuery.from_statement�
s/��&�$�$��%�%�y��
�	�$����r�c��|j�|j�j�S|jd�j�j�S)a�Return the first result of this ``Query`` or
        None if the result doesn't contain any row.

        first() applies a limit of one within the generated SQL, so that
        only one primary entity row is generated on the server side
        (note this may consist of multiple result rows if join-loaded
        collections are present).

        Calling :meth:`_query.Query.first`
        results in an execution of the underlying
        query.

        .. seealso::

            :meth:`_query.Query.one`

            :meth:`_query.Query.one_or_none`

            :meth:`_engine.Result.first` - v2 comparable method.

            :meth:`_engine.Result.scalars` - v2 comparable method.

        r)r�rN�firstrEr�s r�rUzQuery.first�
sC��2�?�?�&��:�:�<�%�%�'�'��:�:�a�=�&�&�(�.�.�0�0r�c�>�|j�j�S)a�Return at most one result or raise an exception.

        Returns ``None`` if the query selects
        no rows.  Raises ``sqlalchemy.orm.exc.MultipleResultsFound``
        if multiple object identities are returned, or if multiple
        rows are returned for a query that returns only scalar values
        as opposed to full identity-mapped entities.

        Calling :meth:`_query.Query.one_or_none`
        results in an execution of the
        underlying query.

        .. seealso::

            :meth:`_query.Query.first`

            :meth:`_query.Query.one`

            :meth:`_engine.Result.one_or_none` - v2 comparable method.

            :meth:`_engine.Result.scalar_one_or_none` - v2 comparable method.

        )rN�one_or_noner�s r�rWzQuery.one_or_none�
s��0�z�z�|�'�'�)�)r�c�>�|j�j�S)a�Return exactly one result or raise an exception.

        Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects
        no rows.  Raises ``sqlalchemy.orm.exc.MultipleResultsFound``
        if multiple object identities are returned, or if multiple
        rows are returned for a query that returns only scalar values
        as opposed to full identity-mapped entities.

        Calling :meth:`.one` results in an execution of the underlying query.

        .. seealso::

            :meth:`_query.Query.first`

            :meth:`_query.Query.one_or_none`

            :meth:`_engine.Result.one` - v2 comparable method.

            :meth:`_engine.Result.scalar_one` - v2 comparable method.

        )rN�oner�s r�rYz	Query.one�
rPr�c��	|j�}t|tj�s|S|dS#tj
$rYywxYw)a�Return the first element of the first result or None
        if no rows present.  If multiple rows are returned,
        raises MultipleResultsFound.

          >>> session.query(Item).scalar()
          <Item>
          >>> session.query(Item.id).scalar()
          1
          >>> session.query(Item.id).filter(Item.id < 0).scalar()
          None
          >>> session.query(Item.id, Item.name).scalar()
          1
          >>> session.query(func.count(Parent.id)).scalar()
          20

        This results in an execution of the underlying query.

        .. seealso::

            :meth:`_engine.Result.scalar` - v2 comparable method.

        rN)rYr#�collections_abcrr��
NoResultFound)r��rets  r��scalarzQuery.scalar�
sH��0	��(�(�*�C��c�?�#;�#;�<��
��q�6�M���#�#�	��	�s�+3�3�A	�A	c#�K�|j�}	|Ed{���y7�#t$r|j��wxYw�wr�)rN�
GeneratorExit�_soft_close)r��results  r��__iter__zQuery.__iter__s>���������	������	�
��� ��		�s �?�!��!�?�!�<�?c��|j}|j�}|jj||d|ji��}|j
j
dd�rtd|�j�}|j
j
dd�r&|jjs|j�}|S)N�_sa_orm_load_options�rhrHFz
Result[_T]�filtered)r�rr��executer��_attributesr�r�scalarsr^�unique)r�rrrbs    r�rNzQuery._iter%s��������&�&�(�	�6:�l�l�6J�6J���5�t�7H�7H�I�7K�7
�����!�!�"4�e�<��,��/�7�7�9�F�
���"�"�:�u�5��%�%�0�0��]�]�_�F��
r�c��|j�}	|jr&|j||jj�nd}t
|j|��S#tj
$rd}Y�1wxYwr�)rr��_get_bind_args�get_bindr��UnboundExecutionError�str�compile)r�r�binds   r��__str__z
Query.__str__<sv���&�&�(�	�	��<�<��#�#�I�t�|�|�/D�/D�E��
��9�$�$�T�*�+�+���+�+�	��D�	�s�4A � A8�7A8c��|dd|i|��S)Nrr�r�)r�rrr�s    r�rmzQuery._get_bind_argsJs���)��)�b�)�)r�c��t|d��S)a�Return metadata about the columns which would be
        returned by this :class:`_query.Query`.

        Format is a list of dictionaries::

            user_alias = aliased(User, name="user2")
            q = sess.query(User, User.id, user_alias)

            # this expression:
            q.column_descriptions

            # would return:
            [
                {
                    "name": "User",
                    "type": User,
                    "aliased": False,
                    "expr": User,
                    "entity": User,
                },
                {
                    "name": "id",
                    "type": Integer(),
                    "aliased": False,
                    "expr": User.id,
                    "entity": User,
                },
                {
                    "name": "user2",
                    "type": User,
                    "aliased": True,
                    "expr": user_alias,
                    "entity": user_alias,
                },
            ]

        .. seealso::

            This API is available using :term:`2.0 style` queries as well,
            documented at:

            * :ref:`queryguide_inspection`

            * :attr:`.Select.column_descriptions`

        Tr)rr�s r��column_descriptionszQuery.column_descriptionsMs��b$�D��6�6r�z2.0z�The :meth:`_orm.Query.instances` method is deprecated and will be removed in a future release. Use the Select.from_statement() method or aliased() construct in conjunction with Session.execute() instead.c��|�ktjdd��|jd��}t||j|j|j
|j|j�}tj||�}|jjdd�r|j�}|jjdd�r|j�}|S)zhReturn an ORM result given a :class:`_engine.CursorResult` and
        :class:`.QueryContext`.

        z�Using the Query.instances() method without a context is deprecated and will be disallowed in a future release.  Please make use of :meth:`_query.Query.from_statement` for linking ORM results to arbitrary select constructs.r2)�versionFrrHrg)r�warn_deprecatedrr"rr�r�r�r�	instancesrir�rjrk)r��result_proxy�context�
compile_staterbs     r�rzzQuery.instances�s��� �?�� � �J��
�!�/�/�e�/�D�M�"���'�'��'�'��������!�!�
�G��"�"�<��9�����!�!�"4�e�<��^�^�%�F����!�!�*�e�4��]�]�_�F��
r�z:meth:`_orm.Query.merge_result`zJThe method is superseded by the :func:`_orm.merge_frozen_result` function.)rN�enable_warningsc�0�tj|||�S)akMerge a result into this :class:`_query.Query` object's Session.

        Given an iterator returned by a :class:`_query.Query`
        of the same structure
        as this one, return an identical iterator of results, with all mapped
        instances merged into the session using :meth:`.Session.merge`. This
        is an optimized method which will merge all mapped instances,
        preserving the structure of the result rows and unmapped columns with
        less method overhead than that of calling :meth:`.Session.merge`
        explicitly for each value.

        The structure of the results is determined based on the column list of
        this :class:`_query.Query` - if these do not correspond,
        unchecked errors
        will occur.

        The 'load' argument is the same as that of :meth:`.Session.merge`.

        For an example of how :meth:`_query.Query.merge_result` is used, see
        the source code for the example :ref:`examples_caching`, where
        :meth:`_query.Query.merge_result` is used to efficiently restore state
        from a cache back into a target :class:`.Session`.

        )r�merge_result)r��iterator�loads   r�r�zQuery.merge_result�s��L�#�#�D�(�D�9�9r�c�8�|jd�jtjd��j	t
�j
�jd�}|j�}|�|j|�}tj|�S)a�A convenience method that turns a query into an EXISTS subquery
        of the form EXISTS (SELECT 1 FROM ... WHERE ...).

        e.g.::

            q = session.query(User).filter(User.name == "fred")
            session.query(q.exists())

        Producing SQL similar to:

        .. sourcecode:: sql

            SELECT EXISTS (
                SELECT 1 FROM users WHERE users.name = :name_1
            ) AS anon_1

        The EXISTS construct is usually used in the WHERE clause::

            session.query(User.id).filter(q.exists()).scalar()

        Note that some databases such as SQL Server don't allow an
        EXISTS expression to be present in the columns clause of a
        SELECT.    To select a simple boolean value based on the exists
        as a WHERE, use :func:`.literal`::

            from sqlalchemy import literal

            session.query(literal(True)).filter(q.exists()).scalar()

        .. seealso::

            :meth:`_sql.Select.exists` - v2 comparable method.

        F�1r)r!r�r-�literal_columnr"rGr�with_only_columnsr�r7�exists)r��inner�ezeros   r�r�zQuery.exists�s���V
�"�"�5�)�
�[��+�+�C�0�
1�
�_�;�
<�
'�
'�
)�
�
�q�
!�	��.�.�0�����%�%�e�,�E��z�z�%� � r�c���tjjtjd��}|j	|�jd�j
�S)a�Return a count of rows this the SQL formed by this :class:`Query`
        would return.

        This generates the SQL for this Query as follows:

        .. sourcecode:: sql

            SELECT count(1) AS count_1 FROM (
                SELECT <rest of query follows...>
            ) AS anon_1

        The above SQL returns a single row, which is the aggregate value
        of the count function; the :meth:`_query.Query.count`
        method then returns
        that single integer value.

        .. warning::

            It is important to note that the value returned by
            count() is **not the same as the number of ORM objects that this
            Query would return from a method such as the .all() method**.
            The :class:`_query.Query` object,
            when asked to return full entities,
            will **deduplicate entries based on primary key**, meaning if the
            same primary key value would appear in the results more than once,
            only one object of that primary key would be present.  This does
            not apply to a query that is against individual columns.

            .. seealso::

                :ref:`faq_query_deduplicating`

        For fine grained control over specific columns to count, to skip the
        usage of a subquery or otherwise control of the FROM clause, or to use
        other aggregate functions, use :attr:`~sqlalchemy.sql.expression.func`
        expressions in conjunction with :meth:`~.Session.query`, i.e.::

            from sqlalchemy import func

            # count User records, without
            # using a subquery.
            session.query(func.count(User.id))

            # return count of user "id" grouped
            # by "name"
            session.query(func.count(User.id)).group_by(User.name)

            from sqlalchemy import distinct

            # count distinct "name" values
            session.query(func.count(distinct(User.name)))

        .. seealso::

            :ref:`migration_20_query_usage`

        �*F)r-�funcr_r�r�r!r^)r��cols  r�r_zQuery.countsI��t�h�h�n�n�S�/�/��4�5���"�"�3�'�9�9�%�@�G�G�I�	
r�c�d�t||�}|jjrC|jjD]*}||j|�}|�||_|j}�,t	j
|j�}|r|jdi|��}|j|_|jj||j|jjd|i���}||_|jjj|�|j!�|j"S)aPerform a DELETE with an arbitrary WHERE clause.

        Deletes rows matched by this query from the database.

        E.g.::

            sess.query(User).filter(User.age == 25).delete(synchronize_session=False)

            sess.query(User).filter(User.age == 25).delete(
                synchronize_session="evaluate"
            )

        .. warning::

            See the section :ref:`orm_expression_update_delete` for important
            caveats and warnings, including limitations when using bulk UPDATE
            and DELETE with mapper inheritance configurations.

        :param synchronize_session: chooses the strategy to update the
         attributes on objects in the session.   See the section
         :ref:`orm_expression_update_delete` for a discussion of these
         strategies.

        :param delete_args: Optional dictionary, if present will be passed
         to the underlying :func:`_expression.delete` construct as the ``**kw``
         for the object.  May be used to pass dialect-specific arguments such
         as ``mysql_limit``.

         .. versionadded:: 2.0.37

        :return: the count of rows matched as returned by the database's
          "row count" feature.

        .. seealso::

            :ref:`orm_expression_update_delete`

        �synchronize_sessionrfr�)�
BulkDeleter��before_compile_delete�queryr-�deleter��with_dialect_optionsr�r�rhr�rrrb�after_bulk_delete�close�rowcount)r�r��delete_args�bulk_delrr�delete_rbs        r�r�zQuery.deleteNs��X�d�K�0���=�=�.�.��m�m�9�9���x�~�~�x�8�	��(�%.�H�N��~�~��:��*�*�d�/�/�0���2�g�2�2�A�[�A�G�"&�"6�"6���$(�L�L�$8�$8���L�L�"�5�5�;�;�&�(;�<��%9�%
��!��������/�/��9��������r�c���|xsi}t|||�}|jjrD|jjD]}||j|�}|��||_�!|j}t	j
|j�}|jdd�}|r|j|�}n|j|�}|r|jdi|��}|j|_|jj||j|jj!d|i���}	|	|_|jjj%|�|	j'�|	j(S)a�Perform an UPDATE with an arbitrary WHERE clause.

        Updates rows matched by this query in the database.

        E.g.::

            sess.query(User).filter(User.age == 25).update(
                {User.age: User.age - 10}, synchronize_session=False
            )

            sess.query(User).filter(User.age == 25).update(
                {"age": User.age - 10}, synchronize_session="evaluate"
            )

        .. warning::

            See the section :ref:`orm_expression_update_delete` for important
            caveats and warnings, including limitations when using arbitrary
            UPDATE and DELETE with mapper inheritance configurations.

        :param values: a dictionary with attributes names, or alternatively
         mapped attributes or SQL expressions, as keys, and literal
         values or sql expressions as values.   If :ref:`parameter-ordered
         mode <tutorial_parameter_ordered_updates>` is desired, the values can
         be passed as a list of 2-tuples; this requires that the
         :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`
         flag is passed to the :paramref:`.Query.update.update_args` dictionary
         as well.

        :param synchronize_session: chooses the strategy to update the
         attributes on objects in the session.   See the section
         :ref:`orm_expression_update_delete` for a discussion of these
         strategies.

        :param update_args: Optional dictionary, if present will be passed
         to the underlying :func:`_expression.update` construct as the ``**kw``
         for the object.  May be used to pass dialect-specific arguments such
         as ``mysql_limit``, as well as other special arguments such as
         :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`.

        :return: the count of rows matched as returned by the database's
         "row count" feature.


        .. seealso::

            :ref:`orm_expression_update_delete`

        �preserve_parameter_orderFr�rfr�)�
BulkUpdater��before_compile_updater�r-rr�r�ordered_valuesr�r�r�r�rhr�rrrb�after_bulk_updater�r�)
r�r�r��update_args�bulk_udrr�upd�pporbs
          r�rzQuery.update�sH��p"�'�R���T�6�;�7���=�=�.�.��m�m�9�9���w�}�}�g�6�	��(�$-�G�M�:��=�=�D��j�j�$�+�+�,���o�o�8�%�@���$�#�$�$�f�-�C��*�*�V�$�C��*�#�*�*�9�[�9�C�"�2�2���$(�L�L�$8�$8���L�L�"�5�5�;�;�&�(;�<��%9�%
�� ��������/�/��8��������r�c���|jdd|i|��}||jjk(sJ�ttt	j
|d��}|j
|dd��S)a�Create an out-of-compiler ORMCompileState object.

        The ORMCompileState object is normally created directly as a result
        of the SQLCompiler.process() method being handed a Select()
        or FromStatement() object that uses the "orm" plugin.   This method
        provides a means of creating this ORMCompileState object directly
        without using the compiler.

        This method is used only for deprecated cases, which include
        the .from_self() method for a Query that has multiple levels
        of .from_self() in use, as well as the instances() method.  It is
        also used within the test suite to generate ORMCompileState objects
        for test purposes.

        rrTN)�toplevel�compilerr�)rr�rrr!�_get_plugin_class_for_plugin�_create_orm_context)r�rr�r�compile_state_clss     r�rzQuery._compile_state�sy��&"�t�!�!�D�
�D��D���� 5� 5� D� D�D�D�D�!���8�8��u�E�
��
!�4�4��4�$�5�
�	
r�c��|j|��}t||j|j|j|j|j
�}|S)Nr)rr"rr�r�r�)r�rr}r|s    r��_compile_contextzQuery._compile_context
sR���+�+�-�+�H�
����#�#��#�#��L�L��L�L����

���r�)�returnrer�)r�zIUnion[_ColumnsClauseArgument[Any], Sequence[_ColumnsClauseArgument[Any]]]r�zOptional[Session])r�zMapping[str, Any]r�rJ)r�zIUnion[_ColumnsClauseArgument[Any], Iterable[_ColumnsClauseArgument[Any]]]r��None)r��	Query[_O]r�zQuery[Tuple[_O]])r�z"Optional[_InternalEntityType[Any]])r�rpr�zMapper[Any])r�zIterable[_FromClauseArgument]r�r�r�r�)r�zInstanceState[Any]r�rJ�r�r�)TT)r�rpr�r�r�r�r�r�)r�rpr�r�)r�r�)NNNNN)r��Optional[bool]r�r�r�zOptional[Sequence[str]]r��Optional[InstanceState[Any]]r��
Optional[Any]r�rJ)r�rr�rJ)r�r�)r�z0Union[Select[_T], FromStatement[_T], UpdateBase])T)rr�r�zSelect[Any])FT)rr�r
r�r�z$Union[Select[_T], FromStatement[_T]])NFF)r �
Optional[str]r&r�r$r�r�r|)r r�r(r�r)r�r�rx)r r�r�z
Label[Any])r��Query[Tuple[_MAYBE_ENTITY]]r�zScalarSelect[_MAYBE_ENTITY])r�zQuery[Tuple[_NOT_ENTITY]]r�zScalarSelect[_NOT_ENTITY])r��ScalarSelect[Any])r�r�r�r�)r�r�rBz
Literal[True]r�zRowReturningQuery[Tuple[_O]])r�r�rBzLiteral[False]r�r�)rBr�r��
Query[Any])rBr�r�rJ)rMrr�rJ)r�rJ)r�rH)rSrHr�rJ)r�zOptional[ColumnElement[bool]])r[rPr�rJ)r_�intr�rJ)rdrQr�r�)rirQrjzCallable[..., Any]r�r�r�r�)r�r�)r�rP)rvz0Union[Literal[None, False], _FromClauseArgument]r�rJ)rzr�r�rJ)NN)r��objectr�z,Optional[attributes.QueryableAttribute[Any]]r�z"Optional[_ExternalEntityType[Any]]r�rJ)r�z_EntityType[Any]r�z Optional[Union[Alias, Subquery]]r�r�)r�rRr�rJ)r��_ColumnsClauseArgument[Any]r�rJ)r�r�r�rJ)r�rzr�r�r�rJ)r�r�r�z
Iterable[Any])r��_ColumnExpressionArgument[Any]r�r)r�z_EntityType[_O]r�r�)r�z roles.TypedColumnsClauseRole[_T]r�zRowReturningQuery[Tuple[_T]])r��
_TCCA[_T0]r��
_TCCA[_T1]r�z"RowReturningQuery[Tuple[_T0, _T1]])r�r�r�r�r��
_TCCA[_T2]r�z'RowReturningQuery[Tuple[_T0, _T1, _T2]])
r�r�r�r�r�r�r��
_TCCA[_T3]r�z,RowReturningQuery[Tuple[_T0, _T1, _T2, _T3]])r�r�r�r�r�r�r�r�r��
_TCCA[_T4]r�z1RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4]])r�r�r�r�r�r�r�r�r�r�r��
_TCCA[_T5]r�z6RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])r�r�r�r�r�r�r�r�r�r�r�r�r��
_TCCA[_T6]r�z;RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�z
_TCCA[_T7]r�z@RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])r�r�r�r�)r�r�r�rr�r�)r�r�r�r�)r�rpr�rJ)rz"Callable[[Query[Any]], Query[Any]]r�r�)r�rU)r�zOptional[CompiledCacheType]r�rpr�rWr�r�r�r�r�r�r`r�r�r�r�z Optional[SchemaTranslateMapType]r�r�r{r�r�r�rMrr�rJ)r�rr�rJ)r�r�r�r�r�zOptional[_ForUpdateOfArgument]r�r�r�r�r�rJ)r�zOptional[Dict[str, Any]]r�rr�rJ)r��_ColumnExpressionArgument[bool]r�rJ)r�z=Optional[Union[_InternalEntityType[Any], _JoinTargetElement]])r�r)r
zTUnion[Literal[None, False, _NoArg.NO_ARG], _ColumnExpressionOrStrLabelArgument[Any]]rz(_ColumnExpressionOrStrLabelArgument[Any]r�rJ)rr�r�rJ)rrrr�r�rJ)rr�r�rJ)
r,r_r-�Optional[_OnClauseArgument]r%r�r&r�r�rJ)r,r_r-r�r&r�r�rJ)r6r7r�rJ)r;rr�r)r@r�rAr�r�rJ)rEr`r�rJ)rGr`r�rJ)rLr�r�rJ)r�zList[_T])rryr�rJ)r�zOptional[_T])r�r~)r�zIterator[_T])r�z#Union[ScalarResult[_T], Result[_T]])r�rp)rrrrr�rr�r)r�zList[ORMColumnDescription])r{zCursorResult[Any]r|zOptional[QueryContext]r�r)r�zCUnion[FrozenResult[Any], Iterable[Sequence[Any]], Iterable[object]]r�r�r�z'Union[FrozenResult[Any], Iterable[Any]])r�r@)r�r�)�autoN)r�rNr��Optional[Dict[Any, Any]]r�r�)r��Dict[_DMLColumnArgument, Any]r�rNr�r�r�r�)F)rr�r�rr�r!)rr�r�r")�r��
__module__�__qualname__�__doc__r��__annotations__r�r�r�r�r�r�r�r�r�r�r�r�rH�LABEL_STYLE_LEGACY_ORMr�r�r!�default_compile_optionsr�r"�default_load_optionsr�rr�r�r�r��memoized_propertyr�r�r�r�r�r�r�r�r;r�r�r�r�r�r�r�r�r�r�r�r�rrr
rr%r*r,rr.�
deprecatedr4r;r:r�rHr!r?�became_legacy_20r&�apply_labelsrQr"rUrXr\r`r�rbrmrZrwr{r�r�preload_moduler'r�r�r�r�r�r��_valuesr�rBr�r�r�rgr�r�rhrfrr�rr�r�r�rr<rr�r
rrrrrrr!r#r0r2r4r7r<rBrErGr�rOrSrUrWrYr^rcrNrsrmrvrzr�r�r_r�rrr�r�r�r�r}r}�s����"79�O�3�8�79��4�9�8:��5�:�8:��5�:�26�M�/�6�37�N�0�7��I�t��35�L�0�5�.2�O�+�2�)+�J�&�+� �O�T� �(*�I�%�*�35�L�0�5�%5�%L�%L�L�"�L� "��	�/�/��E��0�/��4�4��D�8��L�-1�O�O�G�
)�;���26�J�/�6�
��#�#�

������&*�(%�
�(%�
#�(%�T�
�
�
�

�
� -�4�$A�#�0�#�BF�#�	
�#� ����L�L�BF����#'��:>��	
��,BF�=��=�#'�=�:>�=�	
�=�+�
���
��
�-1�(,�37�6:�(,�
�)��&��1�	�
4��&�
�
��< �2��(��(�T�&KO�2�!�2�CG�2�	-�2�l#�!�$�	+(��+(��+(��	+(�

�+(�^#���	=
��=
��=
��	=
�


�=
�~
�"�*�)�*�	$�*��*��(�'�(�	"�(��(��1��1��T�_�_�
�	0��&�
�&�� �)� �	� �� ��(�'�(�	"�(��(��7��7�
�,�	)��	)�	
�	9�	
��+��+� -�+�	%�+��+����� .��	��������(�
��
�2����$�����T���L���

��

�
�L�
�!��!�$�L����,�
��
� �
��
�����2�T��� �M��QB�	�QB�n)-�	
�1�
�'�
�&�	
�

�
�$�3��3� �3��3��#�F�#�
�#��#�J�
��
������	��	��T���(�L���T���7�8�
�:>�
C
��C
�
�C
�8�
C
�
�C
�9�	�
C
�J�37�� ��0��
�	���4����4�4��	
��&�����>B��$��7;��	
����4�T�_�_�
�	I��.�
�.��G�	�3�	�	�	��T�_�_�
�	:������G��G�
�+�2�+�
&�+��+��1� �1�*4�1�	+�1��1��6� �6�*4�6�>H�6�	0�6��6��;��;��;��	;�
�;�
6�
;��;��@��@��@��	@�
�@��
@�
;�@��@��E��E��E��	E�
�E��
E��E�
@�E��E��	J��	J��	J��		J�
�	J��
	J��	J��	J�
E�	J��	J��
O��
O��
O��	
O�
�
O��
O��
O��
O��
O�
J�
O��
O���4��	�����(�4�(�>A�(�	�(��(�T��5��	����0�T�_�_�
�	G��(�
�(�����<�4��	��.'��7:� �*-�#�$�!��*-�AD�"'��"'��4���	�
(���
�������%(��?�� ���� ���� 
�!���$�8��8��.��.�`���-1�!��E��E��	E�

+�E��
E��E�
�E��E�N�37��0��?B��	
����"
'���(�*:�;� �<�� �D
����	F����($�T%�B�
�M�M�0�
�0�;�
0�
�0��0�d�
�M�M�(�
�(�;�
(�
�(��(�T��(�*:�;��<���<M�-2�^6�6�:�4�7���(�*:�;�15�i�
��
i�#�i�.�i�
�i��
i�
�i�<��i�\15�M�
�M�#�M�.�M�
�M�
�
M�&��(�)��*�����,�-�.�.��.�`
���(�)�(��(��(�
�	(�*��(�T��(�)�
�*��
���(�)�	�*��	���(�)�(�*��(�T"�0��,�-��.���.1�<*�4"�0�@��.,�*��07��07�d�T�_�_�
�	6��+/�&�'�&�(�&�

�	&��&�P�T���)�5��	�� :�
� :�
� :�
1�
 :�
� :�D6!�p=
�B;A�04�F�7�F�.�F�

�	F�V;A�04�	X�-�X�8�X�.�	X�


�X�v%*�!
�!�!
�14�!
�	�!
�Fr�c�L�eZdZdZej
dd�dd��Zdd�Zy)	�AliasOptionFr2z�The :class:`.AliasOption` object is not necessary for entities to be matched up to a query that is established via :meth:`.Query.from_statement` and now does nothing.c��y)z�Return a :class:`.MapperOption` that will indicate to the
        :class:`_query.Query`
        that the main table has been aliased.

        Nr�)r�r�s  r�r�zAliasOption.__init__$
s�r�c��yr�r�)r�r}s  r��process_compile_statez!AliasOption.process_compile_state1
s��r�N)r�zUnion[Alias, Subquery])r}r!r�r�)r�r�r��
inherit_cacherr�r�r�r�r�r�r�r�!
s2���M��T�_�_�
�	B���
��
r�r�c�2�eZdZdZdd�Zdd�Zedd��Zy)	�BulkUDzrState used for the orm.Query version of update() / delete().

    This object is now specific to Query only.

    c��|jd�|_|j�|jj�|_y)NF)r!r��_validate_query_stater�rk)r�r�s  r�r�zBulkUD.__init__<
s4���,�,�U�3��
��"�"�$��j�j�:�:�<��r�c
��dddtjfdddtjfdddtjfdd	dtjfd
ddtjfd
ddtjfdddtjffD]=\}}}}|t|j|�|�r�&tjd|�d���y)Nr�zlimit()r�zoffset()r�z
order_by()r�r�z
group_by()r�z
distinct()Fr�z2join(), outerjoin(), select_from(), or from_self()r�z1Can't call Query.update() or Query.delete() when z has been called)�operator�is_�eq�getattrr�r�r�)r�r�r��notset�ops     r�r�zBulkUD._validate_query_stateA
s���
�i��x�|�|�<�
�z�4����>�
 �,��H�K�K�@�
 �,��H�K�K�@�
�,��x�|�|�<��D�����	
��D�����	
�+
�&�D�(�F�B�&�g�d�j�j�$�/��8��0�0�19�<���)+
r�c�.�|jjSr�)r�r�r�s r�r�zBulkUD.session[
s���z�z�!�!�!r�N)r�r�r�)r�rR)r�r�r�r�r�r�r�r�r�r�r�r�r�5
s%���=�
�4�"��"r�r�c�0��eZdZdZ						d�fd�Z�xZS)r�zBulkUD which handles UPDATEs.c�@��t�|�|�||_||_yr�)�superr�r��
update_kwargs)r�r�r�r�r�s    �r�r�zBulkUpdate.__init__c
s!���	��������*��r�)r�r�r�r�r�r��r�r�r�r�r��
__classcell__�r�s@r�r�r�`
s,���'�+��+�.�+�0�	+�+r�r�c�,��eZdZdZ				d�fd�Z�xZS)r�zBulkUD which handles DELETEs.c�2��t�|�|�||_yr�)r�r��
delete_kwargs)r�r�r�r�s   �r�r�zBulkDelete.__init__q
s���
	�����*��r�)r�r�r�r�r�r�s@r�r�r�n
s"���'�+��+�0�+�+r�r�c��eZdZerdd�Zyy)�RowReturningQueryc��yr�r�r�s r�r�zRowReturningQuery.tuples}
s��r�N)r�z
Query[_TP])r�r�r�rr�r�r�r�r�r�z
s���	�r�r�)�r��
__future__r�collections.abc�abcr[r��typingrrrrrr	r
rrr
rrrrrrr�rrrrr9�_typingr�baserr|rrrr r!r"r#r$r%r&r'r)r�r*r+r,r-�enginer.r/�eventr0r1r2r3r4r5r>r6�sql._typingr7r8�sql.annotationr9�sql.baser:r;r<r=r>�sql.elementsr?�sql.expressionr@�sql.selectablerArBrCrDrErFrGrH�util.typingrIrJrKrLrMrNrkrO�
path_registryrPr�rQrRr�rS�
engine.cursorrT�engine.interfacesrUrVrWrX�
engine.resultrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrn�_TCCArorp�sql.dmlrqrrrsrtrurvrwrxryrzr{r|�__all__r~�_self_inspects�class_logger�
Identifiedr}�LoaderOptionr�r�r�r�r�r�r�r��<module>rs;���#�)���������������� ���������)�2�2�"�$�!�,�,������������������"��-��5�,�"��!�!�,�#�4�0�)�%�(�(�;�-�!���$�,�,�3��+�,� �$�,�<�5�2�:�,�,�7�A�4�0�1�.�+�$�)�/�1�!�!�!�!�!�!�!�!�A�+�+�$�,�$�5�3�3�&�$�6�+�-�)��N�
#���T����������@2��������N�N����B�K�@2���@2�Fd
�*�)�)�
�(("�("�V+��+�	+��	+���c�#�h��r�

ZeroDay Forums Mini