Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
util.cpython-313.pyc793 linesDownload Raw Back to __pycache__
1�

2��j\E�
�N3�SSKJr SSKrSSKrSSKrSSKrSSKrSSKJr SSKJr SSKJ	r	 SSKJ4r5 SSKJr SSKJr SS	KJ
r
 SS6KJr SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKrSSKJr SSKJr SSKJr SSKJr SSKJ r  SSKJ!r! SSKJ"r" SSK#J$r$ SSK#J%r% SSK#J&r& SSK#J'r' SS K#J(r( SS!K#J)r) SS"K#J*r* SS#K#J+r+ SS$K#J,r, SS%K#J-r- SS&K#J.r. SS'K#J/r/ SS(K#J0r0 SS)K#J1r1 SS*K#J2r2 SS+K#J3r3 SS,K#J4r4 SS-K#J5r5 SS.K#J6r6 SS/K7J8r8 SS0K7J9r9 SS1K7J:r: SS2K7J;r; SS3K7J<r< SS4K=J>r> S5S6KJ?r? S5SKJr@ S5S7KJArA S5S8KJBrB S5S9KJCrC S5S:KDJErE S5S;KBJFrF S5S<KBJGrG S5S=KBJHrH S5S>KBJIrI S5S9KBJCrJ S5S?KBJKrK S5S@KLJMrM S5SAKNJOrO S5SBKPJQrQ S5SCKRJSrS S5SDKRJTrT S5SEKUJVrV S5SFKUJWrW S5SGKXJYrY S5SHKZJ[r[ S5SIK\J]r^ S5SJK\J_r` S5SKK\Jara S5SLK\Jbrb S5SMK\Jcrc S5SNK\Jdrd S5SOK\Jere \R,(a�SSPKJfrf SSQKJgrg SSRKJhrh SSSKJiri SSTKjJkrk SSUKjJlrl SSVKmJnrn SSWK=Joro SSXKpJqrq SSYKrJsrs S5SZKtJuru S5S[KtJvrv S5S\KLJwrw S5S]KLJxrx S5S^KLJyry S5S_KLJzrz S5S`KLJ{r{ S5SaKLJ|r| S5SbKNJ}r} S5ScKPJ~r~ S5SdKUJr S5SeKXJ�r� S5SfKXJ�r� S5SgKXJ�r� S5ShK�J�r� S5SiK\J�r� \"Sj\Sk9r�\�"Sl5r�\GR"\GR\CGR"\.\6\+Sm.5Sn9r�"SoSp\e5r�\7"\�\�"\^55r]"SqSr\e5r�\8"\�\�"\`55r_"SsSt\\�5r�Sur�S�Svjr�S�SSSSw.S�Sxjjjr�"SySz\GR&5r�"S{S|\JGR*5r�"S}S~\JGR*5r�"SS�\AGR0S�\:\5r�\AGR4"S�S�\;\\<\S\,\[\AGR0S�\
\5	5r�"S�S�5r�"S�S�\85r�\AGR<"\�5"S�5 \AGR<"\�5S�S�j5r�\�"\\5r�\AGR<"\�5S�S�j5r�\AGR4"S�S�\:\�\O\T\AGR0S�\,55r�S�S�S�jjr�S�S�jr�S�S�jr�"S�S�\GGRN5r�S�S�S�jjr�S�S�jr�S�S�jr�S�S�jr�S�S�jr�S�S�jr�S�S�jr�S�S�jr�"S�S�\�5r�S�S�jr�S�S�S�jjr�S�S�jr�g)��)�annotationsN)�AbstractSet)�Any)�Callable)�cast)�Dict)�	FrozenSet)�Generic)�Iterable)�Iterator)�List)�Match)�Optional)�Sequence)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�9attributes)�exc)�_O)�insp_is_aliased_class)�insp_is_mapper)�prop_is_relationship)�_class_to_mapper)�_MappedAnnotationBase)�10_never_set)�_none_only_set)�	_none_set)�
attribute_str)�class_mapper)�
DynamicMapped)�InspectionAttr)�instance_str)�Mapped)�
object_mapper)�object_state)�opt_manager_of_class)�
ORMDescriptor)�state_attribute_str)�state_class_str)�	state_str)�WriteOnlyMapped)�CriteriaOption)�MapperProperty)�ORMColumnsClauseRole)�ORMEntityColumnsClauseRole)�ORMFromClauseRole)�PathRegistry�)�event)�11inspection)�sql)�util��result_tuple)�	coercions)�12expression)�lambdas)�roles)�visitors)�
is_selectable)�SupportsCloneAnnotations)�ColumnCollection)�HasCacheKey)�MemoizedHasCacheKey)�
ColumnElement)�KeyedColumnElement)�13FromClause)�
MemoizedSlots)�de_stringify_annotation)�eval_name_only)�fixup_container_fwd_refs)�14get_origin)�is_origin_of_cls)�Literal)�Protocol)�_EntityType)�_IdentityKeyType)�_InternalEntityType)�_ORMCOLEXPR)�
_MapperEntity)�ORMCompileState)�Mapper)�AbstractEntityRegistry)�Query)�RelationshipProperty)�Row)�15RowMapping)�_CE)�_ColumnExpressionArgument)�_EquivalentColumnMap)�_FromClauseArgument)�_OnClauseArgument)�_PropagateAttrsType)�_SA)�ReadOnlyColumnCollection)�
BindParameter)�_ColumnsClauseElement)�Select)�16Selectable)�anon_map)�_AnnotationScanType�_T)�bound)�delete�
delete-orphan�all�merge�expunge�save-update�refresh-expire�none)r'r/r$)�locals_c�>�\rSrSrSSS.SSjjrSrg)�_DeStringifyAnnotation�NF)�str_cleanup_fn�include_genericc��g�N�)�self�cls�17annotation�originating_modulerzr{s      �YD:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/orm/util.py�__call__�_DeStringifyAnnotation.__call__�s���r~)r��	Type[Any]r�rkr��strrzz#Optional[Callable[[str, str], str]]r{�bool�returnr���__name__�18__module__�__qualname__�__firstlineno__r��__static_attributes__r~r�r�rxrx�sO��?C� %��
��(�� �	�<�
���19��r�rxc��\rSrSrSSjrSrg)�
_EvalNameOnly�c��gr}r~)r�name�module_names   r�r��_EvalNameOnly.__call__�s��Cr�r~N)r�r�r�r�r�rr�r~r�r�r�r��s��?r�r�c��^�\rSrSr%Sr\R
/SQ5r\r/SQr	Sr20S\S'S\S'S\S	'S\S21'S\S'S\S'SU4S
jjrSr
\S5rSrU=r$)�CascadeOptions�zDKeeps track of the options sent to22:paramref:`.relationship.cascade`)rpruro)rrrprurtrq)�save_updatern�refresh_expirerqrr�
delete_orphanr�r�rnr�rqrrr�c�>�[U[5(dUcURU5$[U5nUR	UR235(ad[R"SSR[UR	UR2455Vs/sHn[U5PM sn5-5eSU;aURUR5 SU;aUR5 URS5 [TU]AX5nSU;UlSU;UlSU;UlSU;UlS	U;UlS25U;UlUR,(a'UR$(d[.R0"S5 U$s snf)NzInvalid cascade option(s): %s�, rprursrnrtrqrrroz5The 'delete-orphan' cascade option requires 'delete'.)�26isinstancer��from_string�set�27difference�_allowed_cascades�sa_exc�
ArgumentError�join�sorted�repr�update�_add_w_all_cascades�clear�discard�super�__new__r�rnr�rqrrr�r:�warn)r��28value_list�values�xr�	__class__s     �r�r��CascadeOptions.__new__�sb����j�#�&�&�*�*<��?�?�:�.�.��Z������S�2�2�3�3��&�&�/��)�)�"(�"�-�-�c�.C�.C�D�"��"�A��Q��"����29�30
��F�?��M�M�#�1�1�2��V���L�L�N����u���w��s�+��(�F�2����&�(���.�&�8�����&��31� �F�*���,��6������d�k�k��I�I�M�N����3s�Fc�f�SSR[U5Vs/sHoPM sn5-$s snf)NzCascadeOptions(%r)�,)r�r�)rr�s  r��__repr__�CascadeOptions.__repr__�s,��#�s�x�x�F�4�L�0I�L�q��L�0I�'J�K�K��0Is�.32c��[R"SU=(d S5Vs/sH
o"(dMUPM nnU"U5$s snf)Nz\s*,\s*�)�re�split)r��arg�cr�s    r�r��CascadeOptions.from_string�s9���X�X�j�#�)��<�B�<���!�<��B��6�{���Cs33�34A�A)rnr�rrrqr�r�)r�z#Optional[Union[Iterable[str], str]]r�r�)r�r�r�r��__doc__�all_cascadesr�r�r��_viewonly_cascades�	__slots__�__annotations__r�r��classmethodr�r��
__classcell__�r�s@r�r�r��s����)�'�1�1�(���%��N���I����L����K�
�M���#�<�#�	�#�JL����r�r�c�^^^^	�T(dU4Sjm	U(a%U	UUU4SjnU	UUU4SjnU	UUU4SjnU	UUU4SjnOU	UUU4SjnU	UUU4SjnU	UUU4Sjn[R"US	US35S36S9 [R"USUS37S
9 [R"USUS38S39S9 U(a[R"USWS40S41S9 gg)zFRuns a validation method on an attribute value to be set or42appended.43c�R>�URTRnURUL$r})�manager�impl)�state�	initiatorr��keys   �r��detect_is_backref�,_validator_events.<locals>.detect_is_backrefs&����=�=��%�*�*�D��>�>��-�-r�c�>�UR[RLa-T(d
T"X5(dT"UR5TUS5$U$�NF��opr�OP_BULK_REPLACE�obj�r��valuer�r��include_backrefsr��	validators   ����r��append�!_validator_events.<locals>.append	s?����|�|�:�#=�#=�=� �(9�%�(K�(K� �����c�5�%�@�@��r�c	�>�T(d
T"X5(d0UR5nUVs/sHnT"UTUS5PM snUSS&ggs snfr��r��	r�r�r�r�r�r�r�r�r�s	     ����r��bulk_set�#_validator_events.<locals>.bulk_setsO����'8��'J�'J��i�i�k��CI��CI�%�I�c�3��u�5�6���q�	�(K��s�Ac�b>�T(d
T"X5(dT"UR5TUS5$U$r�r��r�r��oldvaluer�r�r�r�r�s    ����r��set_�_validator_events.<locals>.set_s-����'8��'J�'J� �����c�5�%�@�@��r�c�b>�T(d
T"X5(dT"UR5TUS5 gg)NTr�r�s   ����r��remove�!_validator_events.<locals>.removes+����'8��'J�'J��%�)�)�+�s�E�4�8�(Kr�c�>�UR[RLa,T(d
T"X5(dT"UR5TU5$U$r}r�r�s   ����r�r�r�$s=����|�|�:�#=�#=�=� �(9�%�(K�(K� �����c�5�9�9��r�c�>�T(d
T"X5(d/UR5nUVs/sH
nT"UTU5PM snUSS&ggs snfr}r�r�s	     ����r�r�r�,sF����'8��'J�'J��i�i�k��EK�L�V�E�Y�s�C��7�V�L��q�	�(K��Ls�Ac�`>�T(d
T"X5(dT"UR5TU5$U$r}r�r�s    ����r�r�r�1s+����'8��'J�'J� �����c�5�9�9��r�r�T)�raw�retval�bulk_replace)r�r�r�N)r7�listen)44�descr�r��include_removesr�r�r�r�r�r�s45 `` `    @r��_validator_eventsr��s����46�	.��	�	�	�	�	�	�	9�	9�	�	�	M�	M�47	�	�48�L�L��x��T�$�?�	�L�L��~�x�T�:�	�L�L��u�d��T�:��
���T�8�V��d�C�r�c��^^
^�[R"5n0m
0mUH�nXn[R"[R49USS9nX`U'0nURHtnURU:Xa[R"SU<SU<S35eURUR5 X�UR'URTUR'Mv UT
U'M� UU
U4Sjn	/n50UR5H�up�Ub�U51R[R"UVs/sH52o�"X�5PM sn[R "["R$"U55R'U5/-6R)U55 M�U53R[R"UVs/sH54o�"X�5PM sn6R)U55 M� [R*"U556R-U5$s snfs snf)a�Create a ``UNION`` statement used by a polymorphic mapper.56 57See  :ref:`concrete_inheritance` for an example of how58this is used.59 60:param table_map: mapping of polymorphic identities to61 :class:`_schema.Table` objects.62:param typecolname: string name of a "discriminator" column, which will be63 derived from the query, producing the polymorphic identity for64 each row.  If ``None``, no polymorphic discriminator is generated.65:param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()`66 construct generated.67:param cast_nulls: if True, non-existent columns, which are represented68 as labeled NULLs, will be passed into CAST.   This is a legacy behavior69 that is problematic on some backends such as Oracle - in which case it70 can be set to False.71 72T)�allow_selectzPolymorphic union can't use 'z3' as the discriminator column due to mapped column zn; please apply the 'typecolname' argument; this is available on ConcreteBase as '_concrete_discriminator_name'c�8>�TUU$![a� T(a>[R"[R"5TU5R	U5s$[R73"[R"5TU5R	U5s$f=fr})�KeyErrorr9r�null�label�type_coerce)r��table�74cast_nulls�colnamemaps�typess  ���r��col�polymorphic_union.<locals>.colosy���	L��u�%�d�+�+���	L���x�x����75�E�$�K�8�>�>�t�D�D����s�x�x�z�5��;�?�E�E�d�K�K�		L�s��A
B�<B�B)r:�76OrderedSetr=�expectr@�StrictFromClauseRoler�r�r��InvalidRequestError�add�type�itemsr�r9�select�literal_column�sql_util�_quote_ddl_exprr��select_from�	union_all�alias)�	table_map�typecolname�	aliasnamer��colnamesr�r��mr�r�result�type_r�r�r�s   `         @@r��polymorphic_unionr>s����,&*�_�_�%6�H��K��E������� � ��&�&��D�77���#�������A��u�u��#��0�0�#�A�'���
�L�L������a�e�e�H��6�6�E�!�%�%�L����E��-�0L��F�!���)����"��M�M��78�79�6>�?�h�d��T�)�h�?��.�.� (� 8� 8�� ?��#�e�K�0���	��+�e�$�
�
�M�M��80�81�3;�<�8�4�c�$�&�8�<���+�e�$�
�*�(�=�=�&�!�'�'�	�2�2��@��=s�G0�"G5)�instance�row�identity_tokenc�8�Ubc[U5nUcFUc[R"S5eUR[	[82R"U55US9$URX4S9$Ub[U5nURU5$[R"S5e)a�Generate "identity key" tuples, as are used as keys in the83:attr:`.Session.identity_map` dictionary.84 85This function has several call styles:86 87* ``identity_key(class, ident, identity_token=token)``88 89  This form receives a mapped class and a primary key scalar or90  tuple as an argument.91 92  E.g.::93 94    >>> identity_key(MyClass, (1, 2))95    (<class '__main__.MyClass'>, (1, 2), None)96 97  :param class: mapped class (must be a positional argument)98  :param ident: primary key, may be a scalar or tuple argument.99  :param identity_token: optional identity token100 101    .. versionadded:: 1.2 added identity_token102 103 104* ``identity_key(instance=instance)``105 106  This form will produce the identity key for a given instance.  The107  instance need not be persistent, only that its primary key attributes108  are populated (else the key will contain ``None`` for those missing109  values).110 111  E.g.::112 113    >>> instance = MyClass(1, 2)114    >>> identity_key(instance=instance)115    (<class '__main__.MyClass'>, (1, 2), None)116 117  In this form, the given instance is ultimately run though118  :meth:`_orm.Mapper.identity_key_from_instance`, which will have the119  effect of performing a database check for the corresponding row120  if the object is expired.121 122  :param instance: object instance (must be given as a keyword arg)123 124* ``identity_key(class, row=row, identity_token=token)``125 126  This form is similar to the class/tuple form, except is passed a127  database result row as a :class:`.Row` or :class:`.RowMapping` object.128 129  E.g.::130 131    >>> row = engine.execute(text("select * from table where a=1 and b=2")).first()132    >>> identity_key(MyClass, row=row)133    (<class '__main__.MyClass'>, (1, 2), None)134 135  :param class: mapped class (must be a positional argument)136  :param row: :class:`.Row` row returned by a :class:`_engine.CursorResult`137   (must be given as a keyword arg)138  :param identity_token: optional identity token139 140    .. versionadded:: 1.2 added identity_token141 142zident or row is required)rzclass or instance is required)143r#r�r��identity_key_from_primary_key�tupler:�to_list�identity_key_from_rowr(�identity_key_from_instance)�class_�identrrr�mappers      r��identity_keyr$�s���J���f�%���;��}��*�*�+E�F�F��7�7��d�l�l�5�)�*�>�8��
��/�/��0��
�144�	��x�(���0�0��:�:��"�"�#B�C�Cr�c��\rSrSrSr\R"5r\R"5r\R"5r	\R"5r145\R"5r\R"5r\R"5r
\R"5r\R"5r\R"5r\R"5rSrg)�_TraceAdaptRolei�a�Enumeration of all the use cases for ORMAdapter.146 147ORMAdapter remains one of the most complicated aspects of the ORM, as it is148used for in-place adaption of column expressions to be applied to a SELECT,149replacing :class:`.Table` and other objects that are mapped to classes with150aliases of those tables in the case of joined eager loading, or in the case151of polymorphic loading as used with concrete mappings or other custom "with152polymorphic" parameters, with whole user-defined subqueries. The153enumerations provide an overview of all the use cases used by ORMAdapter, a154layer of formality as to the introduction of new ORMAdapter use cases (of155which none are anticipated), as well as a means to trace the origins of a156particular ORMAdapter within runtime debugging.157 158SQLAlchemy 2.0 has greatly scaled back ORM features which relied heavily on159open-ended statement adaption, including the ``Query.with_polymorphic()``160method and the ``Query.select_from_entity()`` methods, favoring161user-explicit aliasing schemes using the ``aliased()`` and162``with_polymorphic()`` standalone constructs; these still use adaption,163however the adaption is applied in a narrower scope.164 165r~N)r�r�r�r�r��enum�auto�ALIASED_INSP�JOINEDLOAD_USER_DEFINED_ALIAS� JOINEDLOAD_PATH_WITH_POLYMORPHIC�JOINEDLOAD_MEMOIZED_ADAPTER�MAPPER_POLYMORPHIC_ADAPTER�WITH_POLYMORPHIC_ADAPTER�#WITH_POLYMORPHIC_ADAPTER_RIGHT_JOIN� DEPRECATED_JOIN_ADAPT_RIGHT_SIDE�ADAPT_FROM_STATEMENT�COMPOUND_EAGER_STATEMENT�LEGACY_SELECT_FROM_ALIASr�r~r�r�r&r&�s����0�9�9�;�L�%)�I�I�K�!�'+�y�y�{�$�"&�)�)�+��"&�����#�y�y�{��*.�)�)�+�'�'+�y�y�{�$�166 �9�9�;�� $�y�y�{�� $�y�y�{�r�r&c�d^�\rSrSrSrSrSSSSSSS.S	U4SjjjrSrU=r$)167�ORMStatementAdapteri$z.ColumnAdapter which includes a role attribute.)�roleNFT��equivalents�adapt_required�allow_label_resolve�anonymize_labels�adapt_on_names�adapt_from_selectablesc168�8>�Xl[T	U]	UUUUUUUS9 g)Nr7)r6r��__init__)169rr6�170selectabler8r9r:r;r<r=r�s171         �r�r?�ORMStatementAdapter.__init__)s1����	�
����#�)� 3�-�)�#9�	�	172r�)r6r&r@rir8�Optional[_EquivalentColumnMap]r9r�r:r�r;r�r<r�r=�!Optional[AbstractSet[FromClause]])	r�r�r�r�r�r�r?r�r�r�s@r�r5r5$sx���8��I�7;�$�$(�!&�$�DH�173��174��175�1764�177��
178�"�179��180��181�!B�182�183r�r5c	�^�\rSrSr%SrSrS\S'S\S'SS	S184S	SS185S	SS.SU4SjjjrS
rSr	U=r186$)�187ORMAdapteriAzYColumnAdapter subclass which excludes adaptation of entities from188non-matching mappers.189 190)r6r#�is_aliased_class�aliased_inspr�rF�Optional[AliasedInsp[Any]]rGNFT)r8r9r:r;r@�limit_on_entityr<r=c��>�XlURUlUcURn[U5(aSUlX lOSUlSUl[TU]UUUUUU(aUROSU	U191S9 g)NTF)r9r:r;�192include_fnr<r=)	r6r#r@rrFrGr�r?�_include_fn)rr6�entityr8r9r:r;r@rIr<r=r�s           �r�r?�ORMAdapter.__init__Ls�����	��m�m������*�*�J� ��(�(�$(�D�!� &��$)�D�!� $�D��
�����)� 3�-�+:�t�'�'��)�#9�	�		193r�c���URRSS5nU(+=(d= URUR5=(d URRU5$)N�parentmapper)�_annotations�get�isar#)r�elemrMs   r�rL�ORMAdapter._include_fnpsF���"�"�&�&�~�t�<���z�O�V�Z�Z����4�O�������8O�Or�)rGrFr#r6)r6r&rM�_InternalEntityType[Any]r8rBr9r�r:r�r;r�r@zOptional[Selectable]rIr�r<r�r=rC)r�r�r�r�r�r�r�r?rLr�r�r�s@r�rErEAs�����194G�I���,�,�7;�$�$(�!&�+/� $�$�DH�"195��"196�)�"197�1984�"199��
"200�"�"201��"202�)�"203��"204��"205�!B�"206�"207�HP�Pr�rEc��\rSrSr%SrS\S'S
SSjjr\SSj5rSSjr	SS	jr208SS209jrSSjrSr
g)�AliasedClassiva'Represents an "aliased" form of a mapped class for usage with Query.210 211The ORM equivalent of a :func:`~sqlalchemy.sql.expression.alias`212construct, this object mimics the mapped class using a213``__getattr__`` scheme and maintains a reference to a214real :class:`~sqlalchemy.sql.expression.Alias` object.215 216A primary purpose of :class:`.AliasedClass` is to serve as an alternate217within a SQL statement generated by the ORM, such that an existing218mapped entity can be used in multiple contexts.   A simple example::219 220    # find all pairs of users with the same name221    user_alias = aliased(User)222    session.query(User, user_alias).join(223        (user_alias, User.id > user_alias.id)224    ).filter(User.name == user_alias.name)225 226:class:`.AliasedClass` is also capable of mapping an existing mapped227class to an entirely new selectable, provided this selectable is column-228compatible with the existing mapped selectable, and it can also be229configured in a mapping as the target of a :func:`_orm.relationship`.230See the links below for examples.231 232The :class:`.AliasedClass` object is constructed typically using the233:func:`_orm.aliased` function.   It also is produced with additional234configuration when using the :func:`_orm.with_polymorphic` function.235 236The resulting object is an instance of :class:`.AliasedClass`.237This object implements an attribute scheme which produces the238same attribute and method interface as the original mapped239class, allowing :class:`.AliasedClass` to be compatible240with any attribute technique which works on the original class,241including hybrid attributes (see :ref:`hybrids_toplevel`).242 243The :class:`.AliasedClass` can be inspected for its underlying244:class:`_orm.Mapper`, aliased selectable, and other information245using :func:`_sa.inspect`::246 247    from sqlalchemy import inspect248 249    my_alias = aliased(MyClass)250    insp = inspect(my_alias)251 252The resulting inspection object is an instance of :class:`.AliasedInsp`.253 254 255.. seealso::256 257    :func:`.aliased`258 259    :func:`.with_polymorphic`260 261    :ref:`relationship_aliased_class`262 263    :ref:`relationship_to_window_function`264 265 266r�r�Nc
��[S[R"U55nURnSn
UcbUR(a6UR267R(aUR268R5nO.URRUUS9nOUR(aSn
Uce[UUUUU(aUOURUbUOURUU	UU269U
5Ul
SURRS3Ulg)N�_InternalEntityType[_O]F�r��flatT�aliased(�))rr8�inspectr#rFr@�_is_subqueryr�_with_polymorphic_selectable�_anonymous_fromclause�AliasedInsp�with_polymorphic_mappers�polymorphic_on�
_aliased_inspr!r�)r�mapped_class_or_acrr�r\r<rd�with_polymorphic_discriminator�270base_alias�use_mapper_path�represents_outer_join�inspr#�
nest_adapterss              r�r?�AliasedClass.__init__�s���%�z�'9�'9�:L�'M�271�������
��=��$�$����)E�)E����-�-�/���7�7�M�M�!�!�N����
"�
"� �M�� � � �(�����,�)��4�4�2�=�/��*�*����!��'272���,#�6�=�=�#9�#9�":�!�<��
r�c�D�URU5nSURRRS3UlXlUR273(aNURH>nX1LdM	[RU5n[X#RRU5 M@ U$)Nr]r^)274r�r#r!r�rf�_is_with_polymorphic�_with_polymorphic_entitiesrX�_reconstitute_from_aliased_insp�setattr)r�rGr��sub_aliased_insp�ents     r�rr�,AliasedClass._reconstitute_from_aliased_insp�s����k�k�#���!�,�"5�"5�"<�"<�"E�"E�!F�a�H���(���,�,�$0�$K�$K� �#�7�&�F�F�(��C��C�!8�!8�!A�!A�3�G�%L��275r�c��URSnURn[X15n[US5(a2[US5(a![R"URU5$[US5(aURSU5n[US5(aURU5n[XU5 U$![a [	5ef=f)Nrfr��__self__�__get__�adapt_to_entity)�__dict__�_target�getattrr��AttributeError�hasattrr��276MethodType�__func__ryrzrs)rr�rf�target�attrs     r��__getattr__�AliasedClass.__getattr__s���	(� �M�M�/�:�M�#�*�*�F��6�'�D�277�4��$�$���z�)B�)B��#�#�D�M�M�4�8�8��4��#�#��<�<��d�+�D��4�*�+�+��'�'�
�6�D��D�t�$����1�	#� �"�"�	#�s�B>�>Cc�z�[X!5n[US5(a2[US5(a![R"URU5$[US5(aURSU5n[US5(a8[R"U5UlURU5n[XU5 U$)Nr�rxryrz)r}rr�r�r�ry�weakref�ref�_weak_entityrzrs)rr��mapped_classrGr�s     r��_get_from_serialized�!AliasedClass._get_from_serializeds���278�|�)���4��$�$���z�)B�)B��#�#�D�M�M�4�8�8��4��#�#��<�<��d�+�D��4�*�+�+�(/���D�(9�L�%��'�'��5�D��D�t�$��r�c�^�S[U5URRR4-$)Nz<AliasedClass at 0x%x; %s>)�idrfr|r��rs r�r��AliasedClass.__repr__6s0��+��t�H����&�&�/�/�/279�280�	281r�c�,�[UR5$r})r�rfr�s r��__str__�AliasedClass.__str__<s���4�%�%�&�&r�)r�rf)	NNFFNNNFF)rgz_EntityType[_O]r�Optional[FromClause]r��
Optional[str]r\r�r<r�rd�Optional[Sequence[Mapper[Any]]]rh�Optional[ColumnElement[Any]]rirHrjr�rkr�)rG�AliasedInsp[_O]r��AliasedClass[_O])r�r�r�r)r�r�r�rrGr�r�r)r�r�)r�r�r�r�r�r�r?r�rrr�r�r�r�r�r~r�r�rXrXvs���9�v�M�282'+�"��$�DH�GK�15� %�&+�8=�+�8=�$�8=��	8=�283�8=��
8=�#B�8=�)E�8=�/�8=��8=� $�8=�t��*��	����"�:���&(��8G��	��.284�'r�rXr�c�\�\rSrSr%SrSrS\RR4S\RR4S\RR4S\RR4S\RR4S	\RR4S285\RR4/rS\S'S
\S'S\S'S\S	'S\S'S\S'S\S'S-Sjr\S.S/Sjj5r\S0S1Sjj5r\S2Sj5rSrS3Sjr\S2Sj5r\S4Sj5r\S5Sj5rS6S jrS7S!jrS8S"jrS9S:S#jjr\(aS9S;S$jjr O\r S%r!S&r"S'r#S(r$S)r%S*r&S+r'S,r(g)<rci@a�Provide an inspection interface for an286:class:`.AliasedClass` object.287 288The :class:`.AliasedInsp` object is returned289given an :class:`.AliasedClass` using the290:func:`_sa.inspect` function::291 292    from sqlalchemy import inspect293    from sqlalchemy.orm import aliased294 295    my_alias = aliased(MyMappedClass)296    insp = inspect(my_alias)297 298Attributes on :class:`.AliasedInsp`299include:300 301* ``entity`` - the :class:`.AliasedClass` represented.302* ``mapper`` - the :class:`_orm.Mapper` mapping the underlying class.303* ``selectable`` - the :class:`_expression.Alias`304  construct which ultimately305  represents an aliased :class:`_schema.Table` or306  :class:`_expression.Select`307  construct.308* ``name`` - the name of the alias.  Also is used as the attribute309  name when returned in a result tuple from :class:`_query.Query`.310* ``with_polymorphic_mappers`` - collection of :class:`_orm.Mapper`311  objects312  indicating all those mappers expressed in the select construct313  for the :class:`.AliasedClass`.314* ``polymorphic_on`` - an alternate column or SQL expression which315  will be used as the "discriminator" for a polymorphic load.316 317.. seealso::318 319    :ref:`inspection_toplevel`320 321)�__weakref__r�r#r@r��_adapt_on_namesrdre�_use_mapper_path�_base_aliasrk�persist_selectable�local_tablerprq�_adapterr|�__clause_element__�_memoized_values�_all_column_expressions�_nest_adaptersr�r�r�r|r@rdrez322Mapper[_O]r#rIrEr�zSequence[Mapper[Any]]zSequence[AliasedInsp[Any]]rqzweakref.ref[AliasedClass[_O]]r�z!Union[Type[_O], AliasedClass[_O]]c���URnURn
[R"U5UlX�lU=Ul=UlUlX@lX`l	[R"U=(d U5Ul323X�lX�lX�l
U(a�SUlXPl/UlURHpnX�LdM	[#UR$UUU	US9n['URUR$R(U5 UR R+UR,5 Mr OSUlU
/Ul[/[0R2U
UU
R4U	SURVs1sHnU	(aMUR324iM snSS9UlU(aA[9U[:5(deUR6R=UR65UlX�lX�l gs snf)NT)rir<rjF)r@r8r<r;r=rI)!rMr#r�r�r�r@r�r�r�rer�r�rkr�rprdrqrXr!rsr�r�rfrEr&r)�_equivalent_columnsr�r�rc�wrapr�r|)rrM�	inspectedr@r�rdrer�r�r<rkrmrgr#�polyrurs                 r�r?�AliasedInsp.__init__�s���'�-�-���!�!��#�K�K��/������	325���	326�$�1�D�4D��	�,��"�;�;�{�':�d�;��� 0��%:�"�+��#�(,�D�%�,D�)�.0�D�+��5�5���%�&����"�#'�'5�(8��C��D�K�K����)=�)=�s�C��3�3�:�:�3�;L�;L�M�6�).�D�%�-3�H�D�)�"��(�(��!��2�2�)�!��6�6�$�6�A�%�����6�$�327"�328��
�$��i��5�5�5�5�%�.�.�3�3�D�M�M�B�D�M�-��)���$s�-G,�<G,Nc���[U[5(aVU(a[R"S5eU(aUR	X4S9$[329R"[RXS9$[UUUUUS9$)Nz+adapt_on_names only applies to ORM elementsr[�r\)rr\r�r<)330r�rIr�r�rr=rr@�AnonymizedFromClauseRolerX)r��elementrr�r\r<s      r��_alias_factory�AliasedInsp._alias_factory�s|���g�z�*�*���*�*�A�����}�}�$�}�:�:� �'�'��2�2�G��� �����-��
r�c���[U5nUS;aU(a[R"S5eURX#US9up�U(dU(aUceUR	US9n[UUU	UUUU331U(+S9$)Nr�z[the 'flat' and 'selectable' arguments cannot be passed simultaneously to with_polymorphic()��	innerjoinr�)r�rdr<rhrjrk)rr�r��_with_polymorphic_argsrbrX)
r��base�classesr@r\re�aliasedr�r<r�r��primary_mapper�mapperss
             r��_with_polymorphic_factory�%AliasedInsp._with_polymorphic_factorys���*�$�/���]�*�t��&�&�7��
�332-�C�C��9�D�333����d��)�)�)�#�9�9�t�9�D�J�����%,�)�+9�,�&/�-�	334�		335r�c��UR5nUc0[RU5n[R"U5UlU$r})r�rXrrr�r�)rrus  r�rM�AliasedInsp.entity7s=�����!���;��>�>�t�D�C� '���C� 0�D���336r�Tc�x�URRURUUS.5RSUS.5$)N)rP�parententity�entity_namespace�orm��compile_state_plugin�plugin_subject)r@�	_annotater#�_set_propagate_attrsr�s r��#_memoized_method___clause_element__�/AliasedInsp._memoized_method___clause_element__Hs@�����(�(� $��� $�$(�
�337��338�%*�d�C�339�
	340r�c��UR$r})rMr�s r�r��AliasedInsp.entity_namespaceSs���{�{�r�c�.�URR$)zMReturn the mapped class ultimately represented by this341:class:`.AliasedInsp`.)r#r!r�s r�r!�AliasedInsp.class_Ws���{�{�!�!�!r�c�|�UR(aURR$[R"U5$r})r�r#�_path_registryr5�342per_mapperr�s r�r��AliasedInsp._path_registry]s,��� � ��;�;�-�-�-��*�*�4�0�0r�c��URURURURURUR343URUR5URURURS.$)N)rMr#rr�r<rdrhrirjrkrm)rMr#r@r�r�rdrer�r�rkr�r�s r��__getstate__�AliasedInsp.__getstate__dsj���k�k��k�k��_�_��I�I�"�2�2�(,�(E�(E�.2�.A�.A��*�*�,�#�4�4�%)�%?�%?�!�0�0�344�	345r�c�|�URUSUSUSUSUSUSUSUSUS	US346US5 g)NrMr#rr�rdrhrirjr<rkrm)r?)rr�s  r��__setstate__�AliasedInsp.__setstate__ssg���
�
��(�O��(�O��'�N��&�M��,�-��2�3��,���#�$��"�#��)�*��/�"�	347r�c	���URnURULde[R"SUR55nURVs1sHoDRiM nnX5:XaU$URU5nUR
USUR(+S9upxURSS9n[UUUURURURS9R$s snf)Nc3�8# �UHoRv� M g7fr})r!��.0�mps  r��	<genexpr>�*AliasedInsp._merge_with.<locals>.<genexpr>�s���"348� =�"�I�I� =�s�r�Tr�)rdrhrjrk)
r#r:�to_setrdr!�unionr�rkrbrXrer�rf)	r�otherr��our_classesr��new_classesr�r�r@s	         r��_merge_with�AliasedInsp._merge_with�s��������{�{�n�,�,�,��k�k�"349� $� =� =�"350�351��,1�+I�+I�J�+I�R�y�y�+I��J��%��L�!�'�'��4�G�,�C�C��T��)D�)D�%D�D�352��� �5�5�4�5�@�353����%,�+0�+?�+?�!�2�2�"'�"=�"=�
354��-�	��Ks�C)c���[U[5(deUURS.nU(aX#S'URR	U5RU5R
SUS.5$)N)r�rP�	proxy_keyr�r�)r�rGr#r��traverser�r�)r�exprr��ds    r��_adapt_element�AliasedInsp._adapt_element�si���$�
�.�.�.�.� � �K�K�355��� �k�N�356
�M�M�"�"�4�(�
�Y�q�\�
!�
!�).�$�G��	357r�c��gr}r~)rr�r�s   r��_orm_adapt_element�AliasedInsp._orm_adapt_element�s��r�c��URnX;aDXRLaU$[URURR3585R$URUR5(aU$SU<SU<35e)Nzmapper z doesn't correspond to )rdr#r}rMr!r�rfrS)rr#�	self_polys   r��_entity_for_mapper�AliasedInsp._entity_for_mapper�sp���1�1�	������$�����K�K����!7�!7���-� ��Z�Z����
$�
$��K�O�&�$�O�O�5r�c���URRupURRU5UR	5VVs0sH!up4URRU5U_M# snn4$s snnfr})r#�_get_clauser�r�r)r�onclause�359replacemapr�params     r��_memoized_attr__get_clause�&AliasedInsp._memoized_attr__get_clause�sq��#�{�{�6�6����M�M�"�"�8�,�#-�"2�"2�"4�
�"4�J�C��
�
�&�&�s�+�U�2�"4�
�360�	361��
s�(A3c��0$r}r~r�s r��_memoized_attr__memoized_values�+AliasedInsp._memoized_attr__memoized_values�s���	r�c�P�UR(a@URRURVs/sHoRPM sn5nOURR5nUVVs/sHup4X0R	U54PM nnn[U5$s snfs snnfr})rpr#�_columns_plus_keysrqr�rD)rru�cols_plus_keysr�rs     r��&_memoized_attr__all_column_expressions�2AliasedInsp._memoized_attr__all_column_expressions�s����$�$�!�[�[�;�;�'+�'F�'F�G�'F����'F�G��N�"�[�[�;�;�=�N�=K�362�<J���S�%�%�c�*�+�N�	�363� ��/�/��H��364365s�B�1B"c�p�XR;aURU$U"U0UD6=URU'nU$r})r�)rr��	callable_�args�kwr�s      r��_memo�AliasedInsp._memo�sC���'�'�'��(�(��-�-�1:�D�1G�B�1G�G�D�!�!�#�&���Lr�c��UR(a&SSRSUR55-nOSnS[U5URRU4-$)Nz(%s)r�c3�L# �UHoRRv� M g7fr})r!r�r�s  r�r��'AliasedInsp.__repr__.<locals>.<genexpr>�s���+�-J�r�	�	�"�"�-J�s�"$r�z<AliasedInsp at 0x%x; %s%s>)rdr�r�r!r�)r�	with_polys  r�r��AliasedInsp.__repr__�sc���(�(�����+�-1�-J�-J�+�"��I��I�,��t�H��K�K� � ��0366�367�	368r�c��^�TR(aBSTRR<SSRU4SjTR55<S3$STRR<S3$)Nzwith_polymorphic(z, [r�c3�r># �UH,nUTRLdMURRv� M. g7fr})r#r!r�)r�r�rs  �r�r��&AliasedInsp.__str__.<locals>.<genexpr>s0�����;������,�'�B�I�I�&�&�;�s�7�7z])r]r^)rpr|r�r�rdr�s`r�r��AliasedInsp.__str__�s_����$�$�$����%�%��	�	��"�;�;����
�%�%)�L�L�$9�$9�;�;r�)r�r�r�rpr�r|r�r�rqr�r#r�r�rerkr@rd)rMr�r�rZr@rIr�r�rdr�rer�r�rHr�r�r<r�rkr�rmr�)NNFF)r�z"Union[_EntityType[_O], FromClause]rr�r�r�r\r�r<r�r�z#Union[AliasedClass[_O], FromClause])FFNFFFNF)r�zUnion[Type[_O], Mapper[_O]]r�z/Union[Literal['*'], Iterable[_EntityType[Any]]]r@z'Union[Literal[False, None], FromClause]r\r�rer�r�r�r�r�r<r�r�r�r�r�r�r�)r�r�)r�rI)r��Type[_O])r�rY)r��Dict[str, Any])r�rr��None)r�r�r�r�r})r�rUr�r�r�rU)r�r^r�r�r�r^))r�r�r�r�r�r�rA�ExtendedInternalTraversal�	dp_string�369dp_boolean�dp_inspectable�dp_clauseelement�InternalTraversal�dp_has_cache_key_list�_cache_key_traversalr�r?r�r�r��propertyrMrFr�r�r!r�r�r�r�r�rr�r�r�r�rrr�r�r�r~r�r�rcrc@s>��$�L�I�2370��3�3�=�=�>�	�H�>�>�I�I�J�	�X�?�?�J�J�K�	�H�6�6�E�E�F�	�x�9�9�J�J�K�&��&�&�<�<�	371�372�8�5�5�F�F�G���
������3�3� :�:�/�/�:�
.�.��J*� �J*�+�J*��	J*�373�J*�#B�
J*�5�J*�0�J*��J*��J*� $�J*��J*�X�'+�"��$�
�3��$���	�374���
�375-����8�376?D��7;���$�"�!&�%377�)�%378�A�%379�<�	%380�381�%382�5�
%383��%384��%385��%386��%387��%388�389�%390��%391�N�������	392������"��"�393�1��1�
394�
395��>7;�396��397�&3�398�	�399�*�"&�	��	��	��		�,��P�400��0��401�<r�rcc�R�\rSrSrSrSrSr\R"S5S5r	Sr402g)�_WrapUserEntityi
z�A wrapper used within the loader_criteria lambda caller so that403we can bypass declared_attr descriptors on unmapped mixins, which404normally emit a warning for such use.405 406might also be useful for other per-lambda instrumentations should407the need arise.408 409��subjectc��Xlgr}r )rr!s  r�r?�_WrapUserEntity.__init__s���r�zsqlalchemy.orm.decl_apic�6�[RRRn[RUS5nXR;aF[URUUR5(aURURU5$[X15$)Nr!)r:�	preloadedr��decl_api�object�__getattribute__r{r��
declared_attr�fgetr})rr�r&r!s    r�r(� _WrapUserEntity.__getattribute__s����>�>�%�%�.�.���)�)�$�	�:���#�#�#�410����T�"�H�$:�$:�)411�)412��#�#�D�)�.�.�w�7�7��7�)�)r�N)r�r�r�r�r�r�r?r:�preload_moduler(r�r~r�r�rr
s3����I��413���2�3�	*�4�	*r�rc���\rSrSr%SrSrS\RR4S\RR4S\RR4S\RR4S\RR4/r
S	\S'S414\S'S\S'S\S
'S\S'S\S'S\S'SSSjjr\S5rSrSSjrSSjrSSjrS SjrS!SjrS"SjrSrg)#�LoaderCriteriaOptioni)z�Add additional WHERE criteria to the load for all occurrences of415a particular entity.416 417:class:`_orm.LoaderCriteriaOption` is invoked using the418:func:`_orm.with_loader_criteria` function; see that function for419details.420 421.. versionadded:: 1.4422 423)�root_entityrM�deferred_where_criteria�where_criteria�_where_crit_orig�include_aliases�propagate_to_loadersr/rMr1r3r4zOptional[Type[Any]]�"Optional[_InternalEntityType[Any]]z9Union[ColumnElement[bool], lambdas.DeferredLambdaElement]r�r0rr2c	�0�[S[R"US55nUc[SU5UlSUlO
SUlXplX l[
U5(ayURb
URnOUceURnSUl[R"U[R[U54[R"US9S9UlO1SUl[R "[RU5UlX@lXPlg)NrVFr�T)�track_closure_variables)�lambda_args�opts)rr8r_r/rMr2�callabler0r?�DeferredLambdaElementr@�WhereHavingRoler�
LambdaOptionsr1r=rr3r4)	r�entity_or_baser1�loader_onlyr3r4r7rM�wrap_entitys	         r�r?�LoaderCriteriaOption.__init__Ps���&����~�u�5�424���>�#�K��@�D���D�K�#�D�� �K� .���N�#�#����+�"�.�.���)�)�)�$�m�m��+/�D�(�")�"?�"?���%�%�,�[�9�;��*�*�,C��	#�D��,1�D�(�"+�"2�"2��%�%�~�#�D�� /��$8�!r�c��[UUUUS9$)N)r3r4)r.)r�rMr1r3r4s     r��	_unreduce�LoaderCriteriaOption._unreduce�s��$���+�!5�	425�	426r�c���[RUR(aURROURUR427URUR44$r})r.rCrMr!r/r2r3r4r�s r��428__reduce__�LoaderCriteriaOption.__reduce__�sP�� �*�*�&*�k�k����"�"�t�7G�7G��%�%��$�$��)�)�	
�429�	430r�c#�# �UR(a)URRRShv�N gUR(de[	URR55nU(aUR
S5n[S[R"USS95nU(aURRShv�N OURUR55 U(aM~ggN�N17f)NrrVF)�raiseerr)rMr#�self_and_descendantsr/�list�__subclasses__�poprr8r_�extend)r�stack�subclassrus    r��_all_mappers�!LoaderCriteriaOption._all_mappers�s�����;�;��{�{�)�)�>�>�>�>��#�#�#�#���)�)�8�8�:�;�E�� �9�9�Q�<���.��&�&�x�%�@����"�z�z�>�>�>�>��L�L��!8�!8�!:�;��%�	
?�?�s(�5C>�C:�BC>�431C<�+C>�8C>�<C>c�X�URRRSS5ULagg)N�for_loader_criteriaFT)�select_statementrQrR�r�
compile_states  r��_should_include�$LoaderCriteriaOption._should_include�s3���*�*�7�7�;�;�%�t�
��
�432�r�c���UR(a0[SURRUR55nOURn[U[5(de[R"USU0SSS9$)N�ColumnElement[bool]rTT)�detect_subquery_cols�ind_cols_on_fromclause)	r0rr1�_resolve_with_argsrMr�rGr�_deep_annotate)r�ext_info�crits   r��_resolve_where_criteria�,LoaderCriteriaOption._resolve_where_criteria�sv���'�'��%��#�#�6�6�x���G��D�433�&�&�D��$�
�.�.�.�.��&�&��
"�D�)�!%�#'�	434�	435r�c�&�URU5 gr})�process_compile_state)rrW�mapper_entitiess   r��'process_compile_state_replaced_entities�<LoaderCriteriaOption.process_compile_state_replaced_entities�s��436	
�"�"�=�1r�c�:�URUR5 g)z7Apply a modification to a given :class:`.CompileState`.N)�get_global_criteria�global_attributesrVs  r�re�*LoaderCriteriaOption.process_compile_state�s��	
� � ��!@�!@�Ar�c�~�UR5H)nUR"SU4/5nURU5 M+ g)N�additional_entity_criteria)rQ�437setdefaultr�)rrr��
load_criterias    r�rj�(LoaderCriteriaOption.get_global_criteria�s?���#�#�%�B�&�1�1�-�r�2�B��M�
� � ��&�&r�)r2r0rMr3r4r/r1N)FFTT)r>z_EntityType[Any]r1zXUnion[_ColumnExpressionArgument[bool], Callable[[Any], _ColumnExpressionArgument[bool]]]r?r�r3r�r4r�r7r�)r�zIterator[Mapper[Any]])rWrWr�r�)r`rVr�r[)rWrWrfzIterable[_MapperEntity]r�r)rWrWr�r)rzDict[Any, Any]r�r)r�r�r�r�r�r�rAr�dp_plain_obj�dp_has_cache_keyrrr�_traverse_internalsr�r?r�rCrFrQrXrbrgrerjr�r~r�r�r.r.)sZ��	��I�438��:�:�G�G�H�	�8�5�5�F�F�G�	�8�5�5�F�F�G�	�H�6�6�A�A�B�	��!;�!;�!F�!F�G���%�$�.�.�M�M�!�!�������"� %�%)�(,�/9�(�/9�439�/9��/9��/9�#�/9�"&�/9�b�440��441�	442�<�"�443�0�444�	�445�$2�&�2�1�2�446�	2�B�'r�r.c��UR$r})rf)r�s r��<lambda>rv�s447��&�2F�2Fr�c��[U5nUbUR(dgURnU$![Ra gf=fr})r*�	is_mappedr#r�NO_STATE)r!�
class_managerr#s   r��_inspect_mcr{�sL���,�V�4�
�� �
�(?�(?���%�%���
���<�<����s�0�0�A�Ac�B�[S[U55n[U5$)Nr)rrNr{)r!�origins  r��_inspect_generic_aliasr~�s ���*�j��0�
1�F��v��r�c�>�\rSrSr%SrSrSrSrSrSr	\448R"5rS\
S'\449RrS\
S'SS	jrSS450jr\SSj5r\SSj5r\SSj5rS
\
S'S
\
S'SrSr\S5rSrSSjrSrg)�Bundlei�a�A grouping of SQL expressions that are returned by a :class:`.Query`451under one namespace.452 453The :class:`.Bundle` essentially allows nesting of the tuple-based454results returned by a column-oriented :class:`_query.Query` object.455It also456is extensible via simple subclassing, where the primary capability457to override is that of how the set of expressions should be returned,458allowing post-processing as well as custom return types, without459involving ORM identity-mapped classes.460 461.. seealso::462 463    :ref:`bundles`464 465 466FTrc�_propagate_attrszList[_ColumnsClauseElement]�exprsc467��U=UlUlUVs/sH&n[R"[R468X@S9PM( nnXPl[SUVs/sHofRRSU5PM  sn55R5=UlUlURSUR5Ulgs snfs snf)a�Construct a new :class:`.Bundle`.469 470e.g.::471 472    bn = Bundle("mybundle", MyClass.x, MyClass.y)473 474    for row in session.query(bn).filter(bn.c.x == 5).filter(bn.c.y == 4):475        print(row.mybundle.x, row.mybundle.y)476 477:param name: name of the bundle.478:param \*exprs: columns or SQL expressions comprising the bundle.479:param single_entity=False: if True, rows for this :class:`.Bundle`480 can be returned as a "single entity" outside of any enclosing tuple481 in the same manner as a mapped entity.482 483)�apply_propagate_attrsc3�T# �UHn[USUR5U4v� M  g7f)r�N)r}�_label)r�rs  r�r��"Bundle.__init__.<locals>.<genexpr>As)���1484�O���S�%����
,�c�2�O�s�&(�bundle�
single_entityN)r�r�r=rr@�ColumnsClauseRoler�rDrQrR�as_readonlyr��columnsrMr�)rr�r�rr��
coerced_exprs�es       r�r?�Bundle.__init__%s���&#'�&��	�D�K�485�	486���
����'�'��
��		�487�#�488� 0�1489�AN�O��A���*�*�8�Q�7��O�1490�!491��+�-�	����� �V�V�O�T�5G�5G�H����492��Ps�-C�%C493c494��URURUR4[URVs/sHo3RX5PM sn5-$s snfr})r�r�r�rr��_gen_cache_key)rrj�495bindparamsr�s    r�r��Bundle._gen_cache_keyGsP������	�	�4�+=�+=�>��CG�:�:�N�:�4�
 �
 ��
6�:�N�B496�497�	498��Ns�A499c�X�URSRRSS5nU$)NrrP�r�rQrR)rr�s  r�r#�
Bundle.mapperNs,��$(�J�J�q�M�$>�$>�$B�$B��D�%500���	r�c�X�URSRRSS5nU$)Nrr�r�)r�ies  r�rM�
Bundle.entityUs-��15���
�2501�502�,�s�s�>�4�0�	��	r��6ReadOnlyColumnCollection[str, KeyedColumnElement[Any]]c��UR$r})r�r�s r�r��Bundle.entity_namespace\s
���v�v�
r�r�r�c��URRUR5nURRUR5 U$r})r�r�r{r�)rr�cloneds   r��_clone�
Bundle._clones5�����'�'����7�������t�}�}�-��
r�c	��XS.nUR"UR5 URSRR	SUR5035n[R"URVs/sHo3RR	SU5PM  sn[RSS.6RU5RSUS.5$s snf)	N)r�r�rr�r�F)�_literal_as_text_role�groupr�r�)r�rQr�r�rRrMr>�504ClauseListr@r�r�r�)rrr�r�s    r�r��Bundle.__clause_element__�s���!%�@�����4�,�,�-����A��7�7�;�;��d�k�k�505��
�!�!�<@�:�:�F�:�a�.�.�$�$�X�q�1�:�F�',�&=�&=��
�506�Y�{�
#�
!�
!�-2�&4���	507��Gs�2%Cc�6�UR5R$r})r��clausesr�s r�r��Bundle.clauses�s���&�&�(�0�0�0r�c�2�UR5nXlU$)z<Provide a copy of this :class:`.Bundle` passing a new label.)r�r�)rr�r�s   r�r��Bundle.label�s����������
r�c�^^^�[X3Vs/sHnSPM sn5mSUU4SjjnU$s snf)awProduce the "row processing" function for this :class:`.Bundle`.508 509May be overridden by subclasses to provide custom behaviors when510results are fetched. The method is passed the statement object and a511set of "row processor" functions at query execution time; these512processor functions when given a result row will return the individual513attribute value, which can then be adapted into any kind of return data514structure.515 516The example below illustrates replacing the usual :class:`.Row`517return structure with a straight Python dictionary::518 519    from sqlalchemy.orm import Bundle520 521 522    class DictBundle(Bundle):523        def create_row_processor(self, query, procs, labels):524            "Override create_row_processor to return values as dictionaries"525 526            def proc(row):527                return dict(zip(labels, (proc(row) for proc in procs)))528 529            return proc530 531A result from the above :class:`_orm.Bundle` will return dictionary532values::533 534    bn = DictBundle("mybundle", MyClass.data1, MyClass.data2)535    for row in session.execute(select(bn)).where(bn.c.data1 == "d1"):536        print(row.mybundle["data1"], row.mybundle["data2"])537 538r~c�J>�T"TVs/sH539o"U5PM sn5$s snfr}r~)r�proc�keyed_tuple�procss  ��r�r��)Bundle.create_row_processor.<locals>.proc�s$����e�<�e�d��S�	�e�<�=�=��<s� )rzRow[Any]r�rr;)r�queryr��labels�lr�r�s  `   @r��create_row_processor�Bundle.create_row_processor�s8���L#�6��+?��1�B��+?�@��	>�	>����,@s�*540)r�r�r�r�r�r�N)r�r�r�z_ColumnExpressionArgument[Any]rr)rjrjr�zList[BindParameter[Any]]r�zTuple[Any, ...])r�zOptional[Mapper[Any]])r�r5)r�r�)r�zSelect[Any]r�z#Sequence[Callable[[Row[Any]], Any]]r�z
Sequence[str]r�zCallable[[Row[Any]], Any])r�r�r�r�r�r��is_clause_element�	is_mapperrF�	is_bundler:�
immutabledictr�r��	EMPTY_SET�	proxy_setr?r�rr#rMr�r�r�r�r�r�r�r~r�r�r�r��s9���$�M�<����I����I�,0�,>�,>�,@��)�@����I�&�&� I�� I�!?� I�GJ� I�D541� �542�.F�543�	�544�����������	?����545D�C��0>�=�/��546547�2�1��1��+��+�3�+��	+�548549#�+r�r�z550Bundle[_T]c�6�[R"USS0U5$)z�Deep copy the given ClauseElement, annotating each element with the551"_orm_adapt" flag.552 553Elements within the exclude collection will be cloned but not annotated.554 555�556_orm_adaptT)rr_)r��excludes  r��
_orm_annotater��s���"�"�7�\�4�,@�'�J�Jr�c�,�[R"USS9$)z�Remove annotations that link a column to a particular mapping.557 558Note this doesn't affect "remote" and "foreign" annotations559passed by the :func:`_orm.foreign` and :func:`_orm.remote`560annotators.561 562)r�r�)r��r�_deep_deannotate�r�s r��_orm_deannotater��s���$�$��6��r�c�.�[R"U5$r}r�r�s r��_orm_full_deannotater��s���$�$�W�-�-r�c���\rSrSrSr\RRrSrS563SSjjr	Sr564SS
SjjrSSSjjrS	r
g)�_ORMJoini�z/Extend Join to support ORM constructs as input.TNc		��[S[R"U55n	[S[R"U55n565U566RnX`lXpl[
U[R5(ak[(a+[
UR[R5(deURR5nURn
X�R-
nO2[
U[ 5(aUn
U
R"RnOSn
SnU	RnU
(a�[$R&"X�5(aUnO[
U[(5(deUnU
R+UUSU567SUS9unnnnnnUb>U(a[,R."UUU5nUnO[,R."UUUU5nUnOUnUUl[3U	5(aUR4R7SS5nO%[9U	5(d[;U	5(aU	nOSnUb"UR4R=SU05Ul[?U5=(a U
(+n[@RBREXX#XE5 URFceU(a&U=RF[,RH"U6-sl#U
(d�[KU568SS5(a�U569RLRN(af[SU5705n571U572RLRPnUb@[;U5735(aU574RRRUU5nURFU-Ul#ggggg)Nz+Union[FromClause, _InternalEntityType[Any]]T)�source_selectable�dest_selectable�source_polymorphic�of_type_entity�alias_secondary�extra_criteriar�r#rV)+rr8r_r@�575_left_memo�_right_memor�r�QueryableAttributer�576comparatorr[�577Comparator�_source_selectabler�_extra_criteriar1�parentr�clause_is_presentrI�
_create_joinsr9r��_target_adapterrBrQrRrrr�r�r>�Joinr?r��and_r}r#�single�_single_table_criterionr�r�)r�left�rightr��isouter�fullr�r�r��	left_info�578right_info�adapt_to�
on_selectable�prop�left_selectable�579adapt_from�pj�sj�source�dest�	secondary�target_adapterr��augment_onclause�single_crits                         r�r?�_ORMJoin.__init__�s���9����t�$�580�	�581�9����u�%�582�583��(�(��%��&���h�584� =� =�>�>��}�!��'�'�)=�)H�)H�����%�/�/�B�B�D�M��$�$�D��7�7�7�O�
��.�
1�
1��D� �K�K�2�2�M��D� �M�#�.�.����)�)�-�I�I�*�585�!�/�:�>�>�>�>�,�586��"�"�",� (�#'�)� $�.�
#��
��������~���H�H�Y��r�:�E�!�H��8�8�D�)�R��A�D�!�H���#1�D� ���#�#�*�7�7�;�;����L��I�
&�
&�*?�	�*J�*J�$�L��L��#� $� 1� 1� 7� 7���.�!�D�� ��0�=��X����� � ��U�g�L��}�}�(�(�(���M�M�S�X�X��7�7�M���587�H�d�3�3��!�!�(�(��8�*�E�J�%�+�+�C�C�K��&�(��4�4�",�"5�"5�">�">�{�"K�K� $�
�
�� ;��
�'�)�4�r�c	���Un[U[R5(a-URn[U[R5(aM-URULde[URURURURURURRS9n[UURURURURS9$)z\Splice a join into the center.588 589Given join(a, b) and join(b, c), return join(a, b).join(c)590 591)r�r�r�)r�r�)r�r9r�r�r�r�r�r�r�r�r�)rr��leftmostr�s    r��_splice_into_center�_ORMJoin._splice_into_centerrs�������3�8�8�,�,��}�}�H���3�8�8�,�,��z�z�X�%�%�%���I�I��J�J��M�M��L�L�����(�(�7�7�
592�����K�K��N�N��M�M��)�)�593�	594r�c��[XX$US9$)N)r�r��r�)rr�r�r�r�s     r�r��
_ORMJoin.join�s����X�'�J�Jr�c��[XUSUS9$)NT)r�r�r�)rr�r�r�s    r��	outerjoin�_ORMJoin.outerjoin�s����X�t�$�G�Gr�)rQr�r�r�r�)NFFNNr~)r�rar�rar��Optional[_OnClauseArgument]r�r�r�r�r��
Optional[Any]r�r�r�zTuple[ColumnElement[bool], ...])NFF)595r�rar�r�r�r�r�r�r�r�r�)r�rar�r�r�r�r�r�)r�r�r�r�r�r>r��__visit_name__�
inherit_cacher?r�r�r�r�r~r�r�r�r��s��9��_�_�3�3�N��M�15���$(�%)�;=�w<�!�w<�#�w<�.�	w<�596�w<��
w<�"�w<�#�w<�9�w<�r597�@15���K�"�K�.�K��	K�598�K�599�
K�15��	H�"�H�.�H��	H�600601�H�Hr�r�c�h�[U[5(a[R"S5e[U[R6025(aXUR(aURnURnUb[U5(d[R"SU35eUnOUnURXS9$)a�Create filtering criterion that relates this query's primary entity603to the given related instance, using established604:func:`_orm.relationship()`605configuration.606 607E.g.::608 609    stmt = select(Address).where(with_parent(some_user, User.addresses))610 611The SQL rendered is the same as that rendered when a lazy loader612would fire off from the given parent on that attribute, meaning613that the appropriate state is taken from the parent object in614Python without the need to render joins to the parent table615in the rendered statement.616 617The given property may also make use of :meth:`_orm.PropComparator.of_type`618to indicate the left side of the criteria::619 620 621    a1 = aliased(Address)622    a2 = aliased(Address)623    stmt = select(a1, a2).where(with_parent(u1, User.addresses.of_type(a2)))624 625The above use is equivalent to using the626:func:`_orm.with_parent.from_entity` argument::627 628    a1 = aliased(Address)629    a2 = aliased(Address)630    stmt = select(a1, a2).where(631        with_parent(u1, User.addresses, from_entity=a2)632    )633 634:param instance:635  An instance which has some :func:`_orm.relationship`.636 637:param property:638  Class-bound attribute, which indicates639  what relationship from the instance should be used to reconcile the640  parent/child relationship.641 642:param from_entity:643  Entity in which to consider as the left side.  This defaults to the644  "zero" entity of the :class:`_query.Query` itself.645 646  .. versionadded:: 1.2647 648z@with_parent() accepts class-bound mapped attributes, not stringsz6Expected relationship property for with_parent(), got )�from_entity)649r�r�r�r�rr��_of_typerr�_with_parent)rr�r�mapper_property�prop_ts     r��with_parentr�s���l�$�����"�"�N�650�	651�652�D�*�7�7�	8�	8��=�=��-�-�K��-�-���"�*>��+653�+654��&�&��&�'�)��
�!�������x��A�Ar�c�F�[R"U5nUR$)z�Return True if the given object has a database655identity.656 657This typically corresponds to the object being658in either the persistent or detached state.659 660.. seealso::661 662    :func:`.was_deleted`663 664)r�instance_state�has_identity��object_r�s  r�r665r666�s ��
�%�%�g�.�E����r�c�F�[R"U5nUR$)z�Return True if the given object was deleted667within a session flush.668 669This is regardless of whether or not the object is670persistent or detached.671 672.. seealso::673 674    :attr:`.InstanceState.was_deleted`675 676)rr	�was_deletedrs  r�rr�s ��
�%�%�g�.�E����r�c�2�[U5(a3[U5(a"UR5UR5Lagg[U5(a"UR(aXR;$XL$[	U5(deURU5$)z�determine if 'given' corresponds to 'entity', in terms677of an entity passed to Query that would match the same entity678being referred to elsewhere in the query.679 680TF)rr�r�rdr�
common_parent��givenrMs  r��_entity_corresponds_tors����V�$�$� ��'�'��!�!�#�u�'8�'8�':�:���	�u�	%�	%��!�!��;�;�;�;��?�"��%� � � � �����&�&r�c�>�[U5(aB[U5=(a0 UR(+=(a XL=(d XR;$[U5(dURUR5$UR=(a XR681;$)aPdetermine if 'given' corresponds to 'entity', in terms682of a path of loader options where a mapped attribute is taken to683be a member of a parent entity.684 685e.g.::686 687    someoption(A).someoption(A.b)  # -> fn(A, A) -> True688    someoption(A).someoption(C.d)  # -> fn(A, C) -> False689 690    a1 = aliased(A)691    someoption(a1).someoption(A.b)  # -> fn(a1, A) -> False692    someoption(a1).someoption(a1.b)  # -> fn(a1, a1) -> True693 694    wp = with_polymorphic(A, [A1, A2])695    someoption(wp).someoption(A1.foo)  # -> fn(wp, A1) -> False696    someoption(wp).someoption(wp.A1.foo)  # -> fn(wp, wp.A1) -> True697 698)rr�rqrSr#rdrs  r��$_entity_corresponds_to_use_path_implr%s���*�U�#�#�!�&�)�
P��+�+�+�
P���N�F�.N�.N�$N�	699�700#�6�
*�
*��y�y����'�'�
�#�#�
9��8�8�8�	701r�c��UR(a0XR;=(d URRU5$UR(a&XR;=(d URU5$URU5$)z]determine if 'given' "is a" mapper, in terms of the given702would load rows of type 'mapper'.703 704)rFrdr#rS)rr#s  r��_entity_isarIsn��705
����7�7�7�706�5�<�<�;K�;K��<707�	708�709�	'�	'��7�7�7�L�5�9�9�V�;L�L��y�y�� � r�c���Sn[U[5(a�[R"U5up4n[U[5(a[U[5(a710XC-711S::a/$[U[5(aUS:d[U[5(a
US:aU"5 URX45nUb[U5SSUR2$[U5$US:XaU"5 g[XUS-5S$)z\calculate __getitem__ in terms of an iterable query object712that also has a slice() method.713 714c��[S5e)Nz@negative indexes are not accepted by SQL index / slice operators)�715IndexErrorr~r�r��_no_negative_indexes�&_getitem.<locals>._no_negative_indexes^s���
&�716�	717r�rN�����r)r��slicer:�decode_slice�intrK�step)�iterable_query�itemr�start�stopr!�ress       r��_getitemr'Xs���718��$���� �-�-�d�3���T�
�t�S�!�!��5�#�&�&����!��I����$�$�����t�S�!�!�d�Q�h� �"��"�"�5�/������9�T�D�4�9�9�4�5�5���9���2�:� �"���d�Q�h�7�8��;�;r�c�p�[XUR5n[U[5$![a gf=fr�)rKr�rOr�	NameError)�raw_annotationr��originating_cls�	annotateds    r��_is_mapped_annotationr-sC��719
B�+���!;�!;�720�	� �	�+@�A�A������s�(�7215�5c��\rSrSrSrg)�
_CleanupErrori�r~N)r�r�r�r�r�r~r�r�r/r/�s��r�r/c	�|^	�[R"SU5nU(dU$[URS5U5nU[RLaSnO%[U[5(a
URnOU$/nUnURX'LaUOURS55 URS5n[R"SU5nUcURU5 OMe[R"SUS	5(dt[R"S722US	5(dUSm	SRU	4S
jUS	RS555US	'SRU5S[!U5S-723--nU$![a'n[SUSURS5S35UeSnAff=f![a Us$f=f)Nz^([^ \|]+?)\[(.+)\]$rzFor annotation "z%", could not resolve container type "z[".  Please ensure this type is imported at the module level outside of TYPE_CHECKING blocks�ClassVarr6z^["'].*["']$rz[\[\]]z"' r�c3�N># �UHnSURT5S3v� M g7f)�"N)�strip)r�rT�724stripcharss  �r�r��1_cleanup_mapped_str_annotation.<locals>.<genexpr>�s(����725�6J�d�a��726�727�:�&�'�q�)�6J�s�"%r��[�])r��matchrLr�r)r/�typingr1�728issubclassrr��	TypeErrorr��searchr�r��len)729r�r��mmr��ne�real_symbolrO�inner�g2r5s730         @r��_cleanup_mapped_str_annotationrD�s����731���)�:�	6�B�
�����R�X�X�a�[�*<�=���f�o�o�� ��	��#�4�5�5�!�l�l��!�!�
�E��E�732�
���B�K�[�U�[�[��^�D�
�[�[��^�����0�"�5���=��L�L����
�.
�H�H�(�%��)�4�4�733�	�	�)�U�2�Y�/�/��734��I�I�735�6;�B�i�o�o�c�6J�736�737��b�	��X�X�e�_��s�5�z�A�~�(>�?�738����C����z�l�+�!�x�x��{�m�,.�
.�739�740�	���� �	���	�s/�E8�!F,�7F,�8741F)�"F$�$F)�,F;�:F;c		��Uc<U(a4[R"SURSUSURS35eg[UUU[S9n	U(aU	S4$[U	S7425(a[U	[5(d�U(azU(dg[U	S743S5nU[RLag[U[5(a[U[ 5(ag[R"SURSUS3S
S9eU	S4$[#U	R$5S:wa[R"S5e['U	R$S5U	R(4$![744a n745[R"SUS35U746eSn747A748f[a5nU(a!S	U;a"SUS35UeUn	SnAGNkSnAff=f)z�given an annotation, figure out if it's ``Mapped[something]`` and if749so, return the ``something`` part.750 751Includes error raise scenarios and other options.752 753Nz4Python typing annotation is required for attribute "�.z " when primary argument(s) for "z#" construct are None or not present)rzzCould not interpret annotation zt.  Check that it uses names that are correctly imported at the module level. See chained stack trace for more hints.zMapped[�754__origin__zType annotation for "a" can't be correctly interpreted for Annotated Declarative Table form.  ORM annotations should normally make use of the ``Mapped[]`` generic type, or other ORM-compatible generic type, as a container for the actual type, which indicates the intent that the attribute is mapped. Class variables that are not intended to be mapped by the ORM should use ClassVar[].  To allow Annotated Declarative to disregard legacy annotations which don't use Mapped[] to pass, set "__allow_unmapped__ = True" on the class or a superclass this class.�zlpr)�coderz)Expected sub-type for Mapped[] annotationr)�orm_exc�MappedAnnotationErrorr�rKrDr/r)rrOrr}r:r1r�rr;r+r>�__args__rMrG)
r*r�r�r��attr_cls�required�is_dataclass_field�
expect_mappedrIr,�cer@r}s
             r��_extract_mapped_subtyperR�s��$����/�/���L�L�>��3�%�(��%�%�&�&I�K��
�755�#�,����9�	756�	�,��$����y�,�/�/�7G��,�8757�8758���� ��L�$�?���V�_�_�,�� ���-�-�*��M�3�3� ��3�3�+�C�L�L�>��3�%�@-�-� ���$!�$��&��y�!�!�"�a�'��/�/�;��
�
%�Y�%7�%7��%:�;�� � �759�	760��}���+�+�-�n�-=�>D�
D�761��		��762�#��	�^�3��/�/�1�.�1A�BH�H���	
�#�	��#�s$�E�763G�$E?�?
G�*F<�<Gc�v�[US5(aUR5nOSn[R"X5$)N�_mapper_property_name)rrTr:�clsname_as_plain_name)r�r�s  r��_mapper_property_as_plain_namerV^	s4���t�,�-�-��)�)�+�����%�%�d�1�1r�)�p_unionT)NN)r!zOptional[Type[_T]]r"zUnion[Any, Tuple[Any, ...]]rzOptional[_T]rz%Optional[Union[Row[Any], RowMapping]]rr�r�z_IdentityKeyType[_T])r!rr�zOptional[Mapper[_O]]r})r�rdr�r�r�rd)r�rdr�rd)rr'r�z"attributes.QueryableAttribute[Any]rzOptional[_EntityType[Any]]r�r[)rr'r�r�)rrVrMrVr�r�)rrVr#zMapper[Any]r�r�)r"z764Query[Any]r#rr�r)r*rkr�r�r+r�r�r�)r�r�r�r�r�r�)TT)r*zOptional[_AnnotationScanType]r�rr�r�r�r�rMr�rNr�rOr�rPr�rIr�r�z@Optional[Tuple[Union[_AnnotationScanType, str], Optional[type]]])r�r�r�r�)��765__future__rr'�	functoolsr�r�r:rrrrrr	r766rrr
rrrrrrrrr�r�rrrJ�_typingrrrrr�rrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/�767interfacesr0r1r2r3r4�
path_registryr5r7r�r8r9r:�
engine.resultr<r=r>r?r@rrA�sql._typingrB�sql.annotationrC�sql.baserD�
sql.cache_keyrErF�sql.elementsrGrH�sql.selectablerI�util.langhelpersrJ�util.typingrK�_de_stringify_annotationrL�_eval_name_onlyrMrNrOrPrQrRrSrTrU�contextrVrWr#rXrYr�rZ�
relationshipsr[�enginer\r]r^r_r`rarbrcrdrerfrgrhri�sql.visitorsrjrkrl�	frozensetr��partialr��_de_stringify_partialrxr�r�r�r�rr$�Enumr&�
ColumnAdapterr5rE�InspectablerX�_self_inspectsrcrr.�	_inspectsrr{�GenericAliasr~r�r�r�r�r�r�rr768rrrrr'r-�	Exceptionr/rDrRrVr~r�r��<module>rvs���#���	��
���������������� ��������*�#�)�6�'�*�2�(�0�.��2�.��0�.�&��<�4�(�!�&�8�,�2�)�7������(�����"��'�5�'�'�/�(�-�'�,�M�;�2�$�*�!�"�	���$�)�,�$�&�(��5��3��#�!�7�2�1�/�1�$�3�,�6�'�+�'�1��T�����	���"�)�)�
�������.�*�	769�
�	��	�X�	���1�2J�K���770@�H�@��m�%:�?�%K�L��F�Y�s�^�F�R?D�F=A�O3�f"&�)-�UD�"�15�$(�
UD��UD�&�UD��	UD�771772/�UD�"�
UD��UD�p9+�d�i�i�9+�x773�(�0�0�774�:2P��'�'�2P�jG'����,�-�/C�B�/G�G'�T���I<��r�"��������,�-��B�K�I<��I<�X*�*�8p'�>�p'�f���\�"�#F�G����d����������D��I������l�#������$�����Y���������<�(��Y��Y�xK��.�lH�z���lH�d/3�IB��IB�775,�IB�,�IB��	IB�X
� �"'�#�'�-E�'�	�'�.!776�#�!777�-E�!778�	�!779�H!�$<�NB�'�B�	�B��B�780�	B�*	�I�	�W��W�),�W��W�D��i781�1�i782�	
�i783��i784�785
�	i786�787�i788��
i789��i790��i791��i792�F�i793�X2r�
codekingpro/portable-devtools · Team Ai