
    ,h	<                   N
   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSK#J$r$  SSK#J%r%  SSK#J&r&  SSK#J'r'  SS K#J(r(  SS!K#J)r)  SS"K#J*r*  SS#K#J+r+  SS$K#J,r,  SS%K#J-r-  SS&K#J.r.  SS'K#J/r/  SS(K#J0r0  SS)K#J1r1  SS*K#J2r2  SS+K#J3r3  SS,K#J4r4  SS-K#J5r5  SS.K#J6r6  SS/K7J8r8  SS0K7J9r9  SS1K7J:r:  SS2K7J;r;  SS3K7J<r<  SS4K=J>r>  S5S6KJ?r?  S5SKJr@  S5S7KJArA  S5S8KJBrB  S5S9KJCrC  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  SSPKJfrf  SSQKJgrg  SSRKJhrh  SSSKJiri  SSTKjJkrk  SSUKjJlrl  SSVKmJnrn  SSWK=Joro  SSXKpJqrq  SSYKrJsrs  S5SZKtJuru  S5S[KtJvrv  S5S\KLJwrw  S5S]KLJxrx  S5S^KLJyry  S5S_KLJzrz  S5S`KLJ{r{  S5SaKLJ|r|  S5SbKNJ}r}  S5ScKPJ~r~  S5SdKUJr  S5SeKXJr  S5SfKXJr  S5SgKXJr  S5ShKJr  S5SiK\Jr  \" Sj\Sk9r\" Sl5      r\GR                  " \GR                  \CGR                  " \.\6\+Sm.5      Sn9r " So Sp\e5      r\
" \\" \^5      5      r] " Sq Sr\e5      r\
" \\" \`5      5      r_ " Ss St\\   5      rSu r SSv jr  SSSSSw.           SSx jjjr " Sy Sz\GR&                  5      r " S{ S|\JGR*                  5      r " S} S~\JGR*                  5      r " S S\AGR0                  S   \:\   5      r\AGR4                   " S S\;\   \<\S\,\[\AGR0                  S   \\   5	      5       r " S S5      r " S S\85      r\AGR<                  " \5      " S 5        \AGR<                  " \5          SS j5       r\" \\   5      r\AGR<                  " \5          SS j5       r\AGR4                   " S S\:\   \O\T\AGR0                  S   \,5      5       rSSS jjrSS jrSS jr " S S\GGRN                  5      r S       SS jjrSS jrSS jr      SS jr      SS jrSS jrSS jr        SS jr " S S\5      r      SS jr  S                   SS jjrSS jrg)    )annotationsN)AbstractSet)Any)Callable)cast)Dict)	FrozenSet)Generic)Iterable)Iterator)List)Match)Optional)Sequence)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )
attributes)exc)_O)insp_is_aliased_class)insp_is_mapper)prop_is_relationship)_class_to_mapper)_MappedAnnotationBase)
_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)
inspection)sql)utilresult_tuple)	coercions)
expression)lambdas)roles)visitors)is_selectable)SupportsCloneAnnotations)ColumnCollection)HasCacheKey)MemoizedHasCacheKey)ColumnElement)KeyedColumnElement)
FromClause)MemoizedSlots)de_stringify_annotation)eval_name_only)fixup_container_fwd_refs)
get_origin)is_origin_of_cls)Literal)Protocol)_EntityType)_IdentityKeyType)_InternalEntityType)_ORMCOLEXPR)_MapperEntity)ORMCompileState)Mapper)AbstractEntityRegistry)Query)RelationshipProperty)Row)
RowMapping)_CE)_ColumnExpressionArgument)_EquivalentColumnMap)_FromClauseArgument)_OnClauseArgument)_PropagateAttrsType)_SA)ReadOnlyColumnCollection)BindParameter)_ColumnsClauseElement)Select)
Selectable)anon_map)_AnnotationScanType_T)bound)deletedelete-orphanallmergeexpungesave-updaterefresh-expirenone)r'   r/   r$   )locals_c                  >    \ rS rSrSSS.           SS jjrSrg)_DeStringifyAnnotation   NF)str_cleanup_fninclude_genericc                   g N )selfcls
annotationoriginating_modulerz   r{   s         K/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/orm/util.py__call___DeStringifyAnnotation.__call__   s         r~   )r   	Type[Any]r   rk   r   strrz   z#Optional[Callable[[str, str], str]]r{   boolreturnr   __name__
__module____qualname____firstlineno__r   __static_attributes__r~   r   r   rx   rx      sO     ?C % (  	 <  
 r   rx   c                      \ rS rSrSS jrSrg)_EvalNameOnly   c                    g r}   r~   )r   namemodule_names      r   r   _EvalNameOnly.__call__   s    Cr   r~   N)r   r   r   r   r   r   r   r~   r   r   r   r      s    ?r   r   c                     ^  \ rS rSr% Sr\R                  / SQ5      r\r/ SQr	Sr
S\S'   S\S'   S\S	'   S\S
'   S\S'   S\S'       SU 4S jjrS r\S 5       rSrU =r$ )CascadeOptions   zDKeeps track of the options sent to
:paramref:`.relationship.cascade`)rp   ru   ro   )rr   rp   ru   rt   rq   )save_updatern   refresh_expirerq   rr   delete_orphanr   r   rn   r   rq   rr   r   c                  > [        U[        5      (       d  Uc  U R                  U5      $ [        U5      nUR	                  U R
                  5      (       ad  [        R                  " SSR                  [        UR	                  U R
                  5      5       Vs/ s H  n[        U5      PM     sn5      -  5      eSU;   a  UR                  U R                  5        SU;   a  UR                  5         UR                  S5        [        TU ]A  X5      nSU;   Ul        SU;   Ul        SU;   Ul        SU;   Ul        S	U;   Ul        S
U;   Ul        UR,                  (       a'  UR$                  (       d  [.        R0                  " S5        U$ s  snf )NzInvalid cascade option(s): %s, rp   ru   rs   rn   rt   rq   rr   ro   z5The 'delete-orphan' cascade option requires 'delete'.)
isinstancer   from_stringset
difference_allowed_cascadessa_excArgumentErrorjoinsortedreprupdate_add_w_all_cascadescleardiscardsuper__new__r   rn   r   rq   rr   r   r:   warn)r   
value_listvaluesxr   	__class__s        r   r   CascadeOptions.__new__   sb    j#&&**<??:..ZS2233&&/)) "("--c.C.CD""A Q"
 
 F?MM#112VLLNuws+(F2&(.&8&
 F*,6dkkIIMN3s   Fc                f    SSR                  [        U 5       Vs/ s H  oPM     sn5      -  $ s  snf )NzCascadeOptions(%r),)r   r   )r   r   s     r   __repr__CascadeOptions.__repr__   s,    #sxxF4L0ILqL0I'JKK0Is   .
c                    [         R                  " SU=(       d    S5       Vs/ s H  o"(       d  M  UPM     nnU " U5      $ s  snf )Nz\s*,\s* )resplit)r   argcr   s       r   r   CascadeOptions.from_string   s9    XXj#)<B<!<B6{ Cs
   
AA)rn   r   rr   rq   r   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#<#	#JL  r   r   c                  ^^^^	 T(       d  U4S jm	U(       a%  U	UUU4S jnU	UUU4S jnU	UUU4S jnU	UUU4S jnOU	UUU4S jnU	UUU4S jnU	UUU4S jn[         R                  " U S	US
S
S9  [         R                  " U SUS
S9  [         R                  " U SUS
S
S9  U(       a  [         R                  " U SWS
S
S9  gg)zFRuns a validation method on an attribute value to be set or
appended.
c                R   > U R                   T   R                  nUR                  UL$ r}   )managerimpl)state	initiatorr   keys      r   detect_is_backref,_validator_events.<locals>.detect_is_backref  s&    ==%**D>>--r   c                   > UR                   [        R                  La-  T(       d  T" X5      (       d  T" U R                  5       TUS5      $ U$ NFopr   OP_BULK_REPLACEobjr   valuer   r   include_backrefsr   	validators      r   append!_validator_events.<locals>.append	  s?    ||:#=#== (9%(K(K c5%@@r   c           	        > T(       d  T" X5      (       d0  U R                  5       nU Vs/ s H  nT" UTUS5      PM     snUS S & g g s  snf r   r   	r   r   r   r   r   r   r   r   r   s	        r   bulk_set#_validator_events.<locals>.bulk_set  sO    '8'J'JiikCICI%Ic3u56q	 (Ks   Ac                b   > T(       d  T" X5      (       d  T" U R                  5       TUS5      $ U$ r   r   r   r   oldvaluer   r   r   r   r   s       r   set__validator_events.<locals>.set_  s-    '8'J'J c5%@@r   c                b   > T(       d  T" X5      (       d  T" U R                  5       TUS5        g g )NTr   r   s      r   remove!_validator_events.<locals>.remove  s+    '8'J'J%))+sE48 (Kr   c                   > UR                   [        R                  La,  T(       d  T" X5      (       d  T" U R                  5       TU5      $ U$ r}   r   r   s      r   r   r   $  s=    ||:#=#== (9%(K(K c599r   c                   > T(       d  T" X5      (       d/  U R                  5       nU Vs/ s H  nT" UTU5      PM     snUS S & g g s  snf r}   r   r   s	        r   r   r   ,  sF    '8'J'JiikEKLVEYsC7VLq	 (KLs   Ac                `   > T(       d  T" X5      (       d  T" U R                  5       TU5      $ U$ r}   r   r   s       r   r   r   1  s+    '8'J'J c599r   r   T)rawretvalbulk_replace)r   r   r   N)r7   listen)
descr   r   include_removesr   r   r   r   r   r   s
    `` `    @r   _validator_eventsr      s    
 	. 	 		 		 		9 	9	 		M 	M
	 	 
LLxT$?	LL~xT:	LLudT:T8VdC r   c                  ^^^ [         R                  " 5       n0 m0 mU  H  nX   n[        R                  " [        R
                  USS9nX`U'   0 nUR                   Ht  nUR                  U:X  a  [        R                  " SU< SU< S35      eUR                  UR                  5        XUR                  '   UR                  TUR                  '   Mv     UTU'   M     UUU4S jn	/ n
U R                  5        H  u  pUb  U
R                  [        R                  " U Vs/ s H
  o" X5      PM     sn[        R                   " ["        R$                  " U5      5      R'                  U5      /-   6 R)                  U5      5        M  U
R                  [        R                  " U Vs/ s H
  o" X5      PM     sn6 R)                  U5      5        M     [        R*                  " U
6 R-                  U5      $ s  snf s  snf )a  Create a ``UNION`` statement used by a polymorphic mapper.

See  :ref:`concrete_inheritance` for an example of how
this is used.

:param table_map: mapping of polymorphic identities to
 :class:`_schema.Table` objects.
:param typecolname: string name of a "discriminator" column, which will be
 derived from the query, producing the polymorphic identity for
 each row.  If ``None``, no polymorphic discriminator is generated.
:param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()`
 construct generated.
:param cast_nulls: if True, non-existent columns, which are represented
 as labeled NULLs, will be passed into CAST.   This is a legacy behavior
 that is problematic on some backends such as Oracle - in which case it
 can be set to False.

T)allow_selectzPolymorphic 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  >  TU   U    $ ! [          a    T(       a>  [        R                  " [        R                  " 5       TU    5      R	                  U 5      s $ [        R
                  " [        R                  " 5       TU    5      R	                  U 5      s $ f = fr}   )KeyErrorr9   r   nulllabeltype_coerce)r   table
cast_nullscolnamemapstypess     r   colpolymorphic_union.<locals>.colo  sy    	Lu%d++ 	Lxx
E$K8>>tDDsxxz5;?EEdKK		Ls    AB<BB)r:   
OrderedSetr=   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   , &*__%6HKE  &&D
 #Auu#00 #A'  LLaeeH66E!%%L  E- 0L F!)"MM

6>?hdT)h?.. ( 8 8 ?#eK0	 +e$ MM

3;<84c$&8<+e$ *( ==&!''	22 @ =s   G0"G5)instancerowidentity_tokenc               8   U bc  [        U 5      nUcF  Uc  [        R                  " S5      eUR                  [	        [
        R                  " U5      5      US9$ UR                  X4S9$ Ub  [        U5      nUR                  U5      $ [        R                  " S5      e)a  Generate "identity key" tuples, as are used as keys in the
:attr:`.Session.identity_map` dictionary.

This function has several call styles:

* ``identity_key(class, ident, identity_token=token)``

  This form receives a mapped class and a primary key scalar or
  tuple as an argument.

  E.g.::

    >>> identity_key(MyClass, (1, 2))
    (<class '__main__.MyClass'>, (1, 2), None)

  :param class: mapped class (must be a positional argument)
  :param ident: primary key, may be a scalar or tuple argument.
  :param identity_token: optional identity token

    .. versionadded:: 1.2 added identity_token


* ``identity_key(instance=instance)``

  This form will produce the identity key for a given instance.  The
  instance need not be persistent, only that its primary key attributes
  are populated (else the key will contain ``None`` for those missing
  values).

  E.g.::

    >>> instance = MyClass(1, 2)
    >>> identity_key(instance=instance)
    (<class '__main__.MyClass'>, (1, 2), None)

  In this form, the given instance is ultimately run though
  :meth:`_orm.Mapper.identity_key_from_instance`, which will have the
  effect of performing a database check for the corresponding row
  if the object is expired.

  :param instance: object instance (must be given as a keyword arg)

* ``identity_key(class, row=row, identity_token=token)``

  This form is similar to the class/tuple form, except is passed a
  database result row as a :class:`.Row` or :class:`.RowMapping` object.

  E.g.::

    >>> row = engine.execute(text("select * from table where a=1 and b=2")).first()
    >>> identity_key(MyClass, row=row)
    (<class '__main__.MyClass'>, (1, 2), None)

  :param class: mapped class (must be a positional argument)
  :param row: :class:`.Row` row returned by a :class:`_engine.CursorResult`
   (must be given as a keyword arg)
  :param identity_token: optional identity token

    .. versionadded:: 1.2 added identity_token

zident or row is required)r  zclass or instance is required)
r#   r   r   identity_key_from_primary_keytupler:   to_listidentity_key_from_rowr(   identity_key_from_instance)class_identr  r  r  mappers         r   identity_keyr$    s    J f%;}**+EFF77dll5)*> 8   // 0   
	x(00::""#BCCr   c                     \ rS rSrSr\R                  " 5       r\R                  " 5       r\R                  " 5       r	\R                  " 5       r
\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       rSrg)_TraceAdaptRolei  a  Enumeration of all the use cases for ORMAdapter.

ORMAdapter remains one of the most complicated aspects of the ORM, as it is
used for in-place adaption of column expressions to be applied to a SELECT,
replacing :class:`.Table` and other objects that are mapped to classes with
aliases of those tables in the case of joined eager loading, or in the case
of polymorphic loading as used with concrete mappings or other custom "with
polymorphic" parameters, with whole user-defined subqueries. The
enumerations provide an overview of all the use cases used by ORMAdapter, a
layer of formality as to the introduction of new ORMAdapter use cases (of
which none are anticipated), as well as a means to trace the origins of a
particular ORMAdapter within runtime debugging.

SQLAlchemy 2.0 has greatly scaled back ORM features which relied heavily on
open-ended statement adaption, including the ``Query.with_polymorphic()``
method and the ``Query.select_from_entity()`` methods, favoring
user-explicit aliasing schemes using the ``aliased()`` and
``with_polymorphic()`` standalone constructs; these still use adaption,
however the adaption is applied in a narrower scope.

r~   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 99;L %)IIK!'+yy{$"&))+ "&#yy{*.))+''+yy{$
  99;  $yy{  $yy{r   r&  c                  d   ^  \ rS rSrSrSrSSSSSSS.               S	U 4S jjjrSrU =r$ )
ORMStatementAdapteri$  z.ColumnAdapter which includes a role attribute.)roleNFTequivalentsadapt_requiredallow_label_resolveanonymize_labelsadapt_on_namesadapt_from_selectablesc          
     8   > Xl         [        T	U ]	  UUUUUUUS9  g )Nr7  )r6  r   __init__)
r   r6  
selectabler8  r9  r:  r;  r<  r=  r   s
            r   r?  ORMStatementAdapter.__init__)  s1     	#) 3-)#9 	 	
r   )r6  r&  r@  ri   r8  Optional[_EquivalentColumnMap]r9  r   r:  r   r;  r   r<  r   r=  !Optional[AbstractSet[FromClause]])	r   r   r   r   r   r   r?  r   r   r   s   @r   r5  r5  $  sx    8I 7;$$(!&$DH

 

 4
 
 "
 
 
 !B
 
r   r5  c            	         ^  \ rS rSr% SrSrS\S'   S\S'   SS	S
S	SS
S	SS.                   SU 4S jjjrS rSr	U =r
$ )
ORMAdapteriA  zYColumnAdapter subclass which excludes adaptation of entities from
non-matching mappers.

)r6  r#  is_aliased_classaliased_inspr   rF  Optional[AliasedInsp[Any]]rG  NFT)r8  r9  r:  r;  r@  limit_on_entityr<  r=  c                  > Xl         UR                  U l        Uc  UR                  n[        U5      (       a  SU l        X l        OSU l        S U l        [        TU ]  UUUUUU(       a  U R                  OS U	U
S9  g )NTF)r9  r:  r;  
include_fnr<  r=  )	r6  r#  r@  r   rF  rG  r   r?  _include_fn)r   r6  entityr8  r9  r:  r;  r@  rI  r<  r=  r   s              r   r?  ORMAdapter.__init__L  s     	mm**J (($(D! &$)D! $D) 3-+:t'')#9 	 		
r   c                    UR                   R                  SS 5      nU(       + =(       d=    UR                  U R                  5      =(       d    U R                  R                  U5      $ )Nparentmapper)_annotationsgetisar#  )r   elemrM  s      r   rL  ORMAdapter._include_fnp  sF    ""&&~t<zOVZZ4O8OOr   )rG  rF  r#  r6  )r6  r&  rM  _InternalEntityType[Any]r8  rB  r9  r   r:  r   r;  r   r@  zOptional[Selectable]rI  r   r<  r   r=  rC  )r   r   r   r   r   r   r   r?  rL  r   r   r   s   @r   rE  rE  A  s    
 GI,, 7;$$(!&+/ $$DH"
"
 )"

 4"
 "
 ""
 "
 )"
 "
 "
 !B"
 "
HP Pr   rE  c                      \ rS rSr% SrS\S'            S                   SS jjr\    SS j5       rSS jr	        SS	 jr
SS
 jrSS jrSrg)AliasedClassiv  a'  Represents an "aliased" form of a mapped class for usage with Query.

The ORM equivalent of a :func:`~sqlalchemy.sql.expression.alias`
construct, this object mimics the mapped class using a
``__getattr__`` scheme and maintains a reference to a
real :class:`~sqlalchemy.sql.expression.Alias` object.

A primary purpose of :class:`.AliasedClass` is to serve as an alternate
within a SQL statement generated by the ORM, such that an existing
mapped entity can be used in multiple contexts.   A simple example::

    # find all pairs of users with the same name
    user_alias = aliased(User)
    session.query(User, user_alias).join(
        (user_alias, User.id > user_alias.id)
    ).filter(User.name == user_alias.name)

:class:`.AliasedClass` is also capable of mapping an existing mapped
class to an entirely new selectable, provided this selectable is column-
compatible with the existing mapped selectable, and it can also be
configured in a mapping as the target of a :func:`_orm.relationship`.
See the links below for examples.

The :class:`.AliasedClass` object is constructed typically using the
:func:`_orm.aliased` function.   It also is produced with additional
configuration when using the :func:`_orm.with_polymorphic` function.

The resulting object is an instance of :class:`.AliasedClass`.
This object implements an attribute scheme which produces the
same attribute and method interface as the original mapped
class, allowing :class:`.AliasedClass` to be compatible
with any attribute technique which works on the original class,
including hybrid attributes (see :ref:`hybrids_toplevel`).

The :class:`.AliasedClass` can be inspected for its underlying
:class:`_orm.Mapper`, aliased selectable, and other information
using :func:`_sa.inspect`::

    from sqlalchemy import inspect

    my_alias = aliased(MyClass)
    insp = inspect(my_alias)

The resulting inspection object is an instance of :class:`.AliasedInsp`.


.. seealso::

    :func:`.aliased`

    :func:`.with_polymorphic`

    :ref:`relationship_aliased_class`

    :ref:`relationship_to_window_function`


r   r   Nc                   [        S[        R                  " U5      5      nUR                  nSnUcb  UR                  (       a6  UR
                  R                  (       a  UR
                  R                  5       nO.UR                  R                  UUS9nOUR                  (       a  SnUc   e[        U UUUU(       a  UOUR                  Ub  UOUR                  UU	UU
U5      U l        SUR                  R                   S3U l        g )N_InternalEntityType[_O]Fr   flatTaliased())r   r8   inspectr#  rF  r@  _is_subqueryr  _with_polymorphic_selectable_anonymous_fromclauseAliasedInspwith_polymorphic_mapperspolymorphic_on_aliased_inspr!  r   )r   mapped_class_or_acr  r   r\  r<  rd  with_polymorphic_discriminator
base_aliasuse_mapper_pathrepresents_outer_joininspr#  nest_adapterss                 r   r?  AliasedClass.__init__  s    %z'9'9:L'M
 =$$)E)E--/ 77MM!! N   "" M   ( , )44 2= /**!'
, #6==#9#9":!<r   c                D   U R                  U 5      nSUR                  R                  R                   S3Ul        Xl        UR
                  (       aN  UR                   H>  nX1Ld  M	  [        R                  U5      n[        X#R                  R                  U5        M@     U$ )Nr]  r^  )
r   r#  r!  r   rf  _is_with_polymorphic_with_polymorphic_entitiesrX  _reconstitute_from_aliased_inspsetattr)r   rG  r   sub_aliased_inspents        r   rr  ,AliasedClass._reconstitute_from_aliased_insp  s     kk#!,"5"5"<"<"E"E!FaH(,,$0$K$K #7&FF(C C!8!8!A!A3G %L 
r   c                    U R                   S   nUR                  n[        X15      n[        US5      (       a2  [        US5      (       a!  [        R                  " UR                  U 5      $ [        US5      (       a  UR                  S U 5      n[        US5      (       a  UR                  U5      n[        XU5        U$ ! [         a    [	        5       ef = f)Nrf  r   __self____get__adapt_to_entity)__dict___targetgetattrr   AttributeErrorhasattrr   
MethodType__func__ry  rz  rs  )r   r   rf  targetattrs        r   __getattr__AliasedClass.__getattr__  s    	( MM/:M #**F6'D
 4$$z)B)B##DMM488 4##<<d+D 4*++''6DDt$1  	# ""	#s   B> >Cc                z   [        X!5      n[        US5      (       a2  [        US5      (       a!  [        R                  " UR                  U 5      $ [        US5      (       a  UR                  S U 5      n[        US5      (       a8  [        R                  " U 5      Ul        UR                  U5      n[        XU5        U$ )Nr   rx  ry  rz  )r}  r  r   r  r  ry  weakrefref_weak_entityrz  rs  )r   r   mapped_classrG  r  s        r   _get_from_serialized!AliasedClass._get_from_serialized  s    
 |)4$$z)B)B##DMM488 4##<<d+D 4*++(/D(9L%''5DDt$r   c                ^    S[        U 5      U R                  R                  R                  4-  $ )Nz<AliasedClass at 0x%x; %s>)idrf  r|  r   r   s    r   r   AliasedClass.__repr__6  s0    +tH&&///
 
 	
r   c                ,    [        U R                  5      $ r}   )r   rf  r  s    r   __str__AliasedClass.__str__<  s    4%%&&r   )r   rf  )	NNFFNNNFF)rg  z_EntityType[_O]r  Optional[FromClause]r   Optional[str]r\  r   r<  r   rd  Optional[Sequence[Mapper[Any]]]rh  Optional[ColumnElement[Any]]ri  rH  rj  r   rk  r   )rG  AliasedInsp[_O]r   AliasedClass[_O])r   r   r   r   )r   r   r  r   rG  r  r   r   )r   r   )r   r   r   r   r   r   r?  r   rr  r  r  r   r  r   r~   r   r   rX  rX  v  s    9v M
 '+"$DHGK15 %&+8=+8= $8= 	8=
 8= 8= #B8= )E8= /8= 8=  $8=t *	 ":&(8G	.
'r   rX  r  c                  \   \ rS rSr% SrSrS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S	\R                  R                  4S
\R                  R                  4/rS\S'   S\S'   S\S'   S\S	'   S\S'   S\S'    S\S'                          S-S jr\    S.           S/S jj5       r\        S0                     S1S jj5       r\S2S j5       rSr S3S jr\S2S j5       r\S4S j5       r\S5S j5       rS6S  jrS7S! jrS8S" jr S9     S:S# jjr\(       a   S9     S;S$ jjr O\r S% r!S& r"S' r#S( r$S) r%S* r&S+ r'S,r(g)<rc  i@  a  Provide an inspection interface for an
:class:`.AliasedClass` object.

The :class:`.AliasedInsp` object is returned
given an :class:`.AliasedClass` using the
:func:`_sa.inspect` function::

    from sqlalchemy import inspect
    from sqlalchemy.orm import aliased

    my_alias = aliased(MyMappedClass)
    insp = inspect(my_alias)

Attributes on :class:`.AliasedInsp`
include:

* ``entity`` - the :class:`.AliasedClass` represented.
* ``mapper`` - the :class:`_orm.Mapper` mapping the underlying class.
* ``selectable`` - the :class:`_expression.Alias`
  construct which ultimately
  represents an aliased :class:`_schema.Table` or
  :class:`_expression.Select`
  construct.
* ``name`` - the name of the alias.  Also is used as the attribute
  name when returned in a result tuple from :class:`_query.Query`.
* ``with_polymorphic_mappers`` - collection of :class:`_orm.Mapper`
  objects
  indicating all those mappers expressed in the select construct
  for the :class:`.AliasedClass`.
* ``polymorphic_on`` - an alternate column or SQL expression which
  will be used as the "discriminator" for a polymorphic load.

.. seealso::

    :ref:`inspection_toplevel`

)__weakref__r  r#  r@  r   _adapt_on_namesrd  re  _use_mapper_path_base_aliasrk  persist_selectablelocal_tablerp  rq  _adapterr|  __clause_element___memoized_values_all_column_expressions_nest_adaptersr   r  r  r|  r@  rd  re  z
Mapper[_O]r#  rI   rE  r  zSequence[Mapper[Any]]zSequence[AliasedInsp[Any]]rq  zweakref.ref[AliasedClass[_O]]r  z!Union[Type[_O], AliasedClass[_O]]c                   UR                   nUR                  n[        R                  " U5      U l        Xl        U=U l        =U l        U l        X@l        X`l	        [        R                  " U=(       d    U 5      U l
        Xl        Xl        Xl        U(       a  SU l        XPl        / U l        U R                   Hp  nXLd  M	  [#        UR$                  UU U	US9n['        U R                   UR$                  R(                  U5        U R                   R+                  UR,                  5        Mr     OSU l        U/U l        [/        [0        R2                  UUUR4                  U	SU R                   Vs1 s H  nU	(       a  M  UR
                  iM     snSS9U l        U(       aA  [9        U[:        5      (       d   eUR6                  R=                  U R6                  5      U l        Xl        Xl         g s  snf )NT)ri  r<  rj  F)r@  r8  r<  r;  r=  rI  )!rM  r#  r  r  r  r@  r  r  r   re  r  r  rk  r  rp  rd  rq  rX  r!  rs  r   r   rf  rE  r&  r)  _equivalent_columnsr  r   rc  wrapr  r|  )r   rM  	inspectedr@  r   rd  re  r  r  r<  rk  rm  rg  r#  polyru  r  s                    r   r?  AliasedInsp.__init__  s    '--!!#KK/	
 	
$1D4D 	,";;{':d; 0%:"+#(,D%,D).0D+55%&"#''5(8C DKK)=)=sC33::3;L;LM 6 ).D%-3HD)"((!22)! 66$6A% 6$
 "
$ i5555%..33DMMBDM-)$s   -G,<G,Nc                    [        U[        5      (       aV  U(       a  [        R                  " S5      eU(       a  UR	                  X4S9$ [
        R                  " [        R                  XS9$ [        UUUUUS9$ )Nz+adapt_on_names only applies to ORM elementsr[  r\  )r  r\  r   r<  )
r   rI   r   r   r  r=   r  r@   AnonymizedFromClauseRolerX  )r   elementr  r   r\  r<  s         r   _alias_factoryAliasedInsp._alias_factory  s|     gz****A  }}$}:: ''22G   - r   c                    [        U5      nUS;  a  U(       a  [        R                  " S5      eUR                  X#US9u  pU(       d  U(       a  Uc   eUR	                  US9n[        UUU	UUUU
U(       + S9$ )Nr   z[the 'flat' and 'selectable' arguments cannot be passed simultaneously to with_polymorphic()	innerjoinr  )r   rd  r<  rh  rj  rk  )r   r   r   _with_polymorphic_argsrb  rX  )r   baseclassesr@  r\  re  aliasedr  r<  r   r  primary_mappermapperss                r   _with_polymorphic_factory%AliasedInsp._with_polymorphic_factory  s     *$/]*t&&7 
 -CC9 D 
 d)))#99t9DJ%,)+9,&/-	
 		
r   c                    U R                  5       nUc0  [        R                  U 5      n[        R                  " U5      U l         U$ r}   )r  rX  rr  r  r  )r   ru  s     r   rM  AliasedInsp.entity7  s=     !;>>tDC 'C 0D
r   Tc                x    U R                   R                  U R                  U U S.5      R                  SU S.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__H  s@    (( $ $$(
 
%*dC
	
r   c                    U R                   $ r}   )rM  r  s    r   r  AliasedInsp.entity_namespaceS  s    {{r   c                .    U R                   R                  $ )zMReturn the mapped class ultimately represented by this
:class:`.AliasedInsp`.)r#  r!  r  s    r   r!  AliasedInsp.class_W  s     {{!!!r   c                |    U R                   (       a  U R                  R                  $ [        R                  " U 5      $ r}   )r  r#  _path_registryr5   
per_mapperr  s    r   r  AliasedInsp._path_registry]  s,      ;;---**400r   c                   U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  5       U R                  U R                  U R                  S.$ )N)rM  r#  r  r   r<  rd  rh  ri  rj  rk  rm  )rM  r#  r@  r   r  rd  re  r  r  rk  r  r  s    r   __getstate__AliasedInsp.__getstate__d  sj    kkkk__II"22(,(E(E.2.A.A**,#44%)%?%?!00
 	
r   c                |    U R                  US   US   US   US   US   US   US   US   US	   US
   US   5        g )NrM  r#  r  r   rd  rh  ri  rj  r<  rk  rm  )r?  )r   r   s     r   __setstate__AliasedInsp.__setstate__s  sg    (O(O'N&M,-23,#$"#)*/"	
r   c           	        UR                   nU R                   UL d   e[        R                  " S U R                   5       5      nUR                   Vs1 s H  oDR                  iM     nnX5:X  a  U$ UR                  U5      nUR                  US UR                  (       + S9u  pxUR                  SS9n[        UUUUR                  UR                  UR                  S9R                  $ s  snf )Nc              3  8   #    U  H  oR                   v   M     g 7fr}   )r!  .0mps     r   	<genexpr>*AliasedInsp._merge_with.<locals>.<genexpr>  s      "
 ="II =s   r  Tr  )rd  rh  rj  rk  )r#  r:   to_setrd  r!  unionr  rk  rb  rX  re  r  rf  )	r   otherr  our_classesr  new_classesr  r  r@  s	            r   _merge_withAliasedInsp._merge_with  s     {{n,,,kk "
 $ = ="
 
 ,1+I+IJ+IRyy+IJ%L!''4G,CCT)D)D%D D 
  5545@
%,+0+?+?!22"'"="=
 -	 Ks   C)c                    [        U[        5      (       d   eU U R                  S.nU(       a  X#S'   U R                  R	                  U5      R                  U5      R                  SU S.5      $ )N)r  rP  	proxy_keyr  r  )r   rG   r#  r  traverser  r  )r   exprr   ds       r   _adapt_elementAliasedInsp._adapt_element  si     $....  KK
  kN
 MM""4(Yq\!!).$G	
r   c                    g r}   r~   )r   r   r   s      r   _orm_adapt_elementAliasedInsp._orm_adapt_element  s     r   c                   U R                   nX;   aD  XR                  L a  U $ [        U R                  UR                  R
                  5      R                  $ UR                  U R                  5      (       a  U $  SU< SU < 35       e)Nzmapper z doesn't correspond to )rd  r#  r}  rM  r!  r   rf  rS  )r   r#  	self_polys      r   _entity_for_mapperAliasedInsp._entity_for_mapper  sp    11	$KK!7!7-  ZZ$$KO&$OO5r   c                    U R                   R                  u  pU R                  R                  U5      UR	                  5        VVs0 s H!  u  p4U R                  R                  U5      U_M#     snn4$ s  snnf r}   )r#  _get_clauser  r  r  )r   onclause
replacemapr   params        r   _memoized_attr__get_clause&AliasedInsp._memoized_attr__get_clause  sq    #{{66MM""8, #-"2"2"4"4JC &&s+U2"4
 	
s   (A3c                    0 $ r}   r~   r  s    r   _memoized_attr__memoized_values+AliasedInsp._memoized_attr__memoized_values  s    	r   c                P   U R                   (       a@  U R                  R                  U R                   Vs/ s H  oR                  PM     sn5      nOU R                  R                  5       nU VVs/ s H  u  p4X0R	                  U5      4PM     nnn[        U5      $ s  snf s  snnf r}   )rp  r#  _columns_plus_keysrq  r  rD   )r   ru  cols_plus_keysr   r   s        r   &_memoized_attr__all_column_expressions2AliasedInsp._memoized_attr__all_column_expressions  s    $$![[;;'+'F'FG'F'FGN "[[;;=N =K
<JS%%c*+N 	 
  // H

s   B1B"c                p    XR                   ;   a  U R                   U   $ U" U0 UD6=U R                   U'   nU$ r}   )r  )r   r   	callable_argskwr   s         r   _memoAliasedInsp._memo  sC    '''((--1:D1GB1GGD!!#&Lr   c                    U R                   (       a&  SSR                  S U R                    5       5      -  nOSnS[        U 5      U R                  R                  U4-  $ )Nz(%s)r   c              3  L   #    U  H  oR                   R                  v   M     g 7fr}   )r!  r   r  s     r   r  'AliasedInsp.__repr__.<locals>.<genexpr>  s      +-Jr		""-Js   "$r   z<AliasedInsp at 0x%x; %s%s>)rd  r   r  r!  r   )r   	with_polys     r   r   AliasedInsp.__repr__  sc    (( +-1-J-J+ " I I,tHKK  0
 
 	
r   c                   ^  T R                   (       aB  ST R                  R                  < SSR                  U 4S jT R                   5       5      < S3$ ST R                  R                  < S3$ )Nzwith_polymorphic(z, [r   c              3  r   >#    U  H,  nUTR                   Ld  M  UR                  R                  v   M.     g 7fr}   )r#  r!  r   )r  r  r   s     r   r  &AliasedInsp.__str__.<locals>.<genexpr>  s0      ;, 'BII&&;s   77z])r]  r^  )rp  r|  r   r   rd  r  s   `r   r  AliasedInsp.__str__  s_    $$$%%		 ";;   % %)LL$9$9;;r   )r  r  r  rp  r  r|  r  r  rq  r  r#  r   r  re  rk  r@  rd  )rM  r  r  rZ  r@  rI   r   r  rd  r  re  r  r  rH  r  r   r<  r   rk  r   rm  r   )NNFF)r  z"Union[_EntityType[_O], FromClause]r  r  r   r  r\  r   r<  r   r   z#Union[AliasedClass[_O], FromClause])FFNFFFNF)r  zUnion[Type[_O], Mapper[_O]]r  z/Union[Literal['*'], Iterable[_EntityType[Any]]]r@  z'Union[Literal[False, None], FromClause]r\  r   re  r  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   r  r   None)r  r  r   r  r}   )r  rU   r   r  r   rU   )r   r^   r   r  r   r^   ))r   r   r   r   r   r   rA   ExtendedInternalTraversal	dp_string
dp_booleandp_inspectabledp_clauseelementInternalTraversaldp_has_cache_key_list_cache_key_traversalr   r?  r   r  r  propertyrM  rF  r  r  r!  r  r  r  r  r  r   r  r  r  r  r  r  r   r  r   r~   r   r   rc  rc  @  s>   $LI2 
33==>	H>>IIJ	X??JJK	H66EEF	x99JJK&&&<<	
 
855FFG 33 :://:..J* J* +J* 	J*
 J* #BJ* 5J* 0J* J* J*  $J* J*X  '+"$3 $ 	
   
- 8 
 ?D7;$"!&%
)%
 A%
 <	%

 %
 5%
 %
 %
 %
 %
 %
 
%
 %
N   	
   " "
 1 1

> 7;

&3
	
*  "&		 	 		 ,P
0
<r   rc  c                  R    \ rS rSrSrSrS r\R                  " S5      S 5       r	Sr
g)_WrapUserEntityi  zA wrapper used within the loader_criteria lambda caller so that
we can bypass declared_attr descriptors on unmapped mixins, which
normally emit a warning for such use.

might also be useful for other per-lambda instrumentations should
the need arise.

subjectc                    Xl         g r}   r   )r   r!  s     r   r?  _WrapUserEntity.__init__  s    r   zsqlalchemy.orm.decl_apic                6   [         R                  R                  R                  n[        R                  U S5      nXR                  ;   aF  [        UR                  U   UR                  5      (       a  UR                  U   R                  U5      $ [        X15      $ )Nr!  )r:   	preloadedr  decl_apiobject__getattribute__r{  r   declared_attrfgetr}  )r   r   r&  r!  s       r   r(   _WrapUserEntity.__getattribute__  s    >>%%..))$	:###
T"H$:$:)
 )
 ##D)..w777))r   N)r   r   r   r   r   r   r?  r:   preload_moduler(  r   r~   r   r   r  r    s3     I 
23	* 4	*r   r  c                     \ rS rSr% SrSrS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4/rS	\S'   S
\S'   S\S'   S\S'   S\S'   S\S'   S\S'       S           SS jjr\S 5       rS rSS jrSS jr    SS jr      S S jrS!S jrS"S jrSrg)#LoaderCriteriaOptioni)  zAdd additional WHERE criteria to the load for all occurrences of
a particular entity.

:class:`_orm.LoaderCriteriaOption` is invoked using the
:func:`_orm.with_loader_criteria` function; see that function for
details.

.. versionadded:: 1.4

)root_entityrM  deferred_where_criteriawhere_criteria_where_crit_originclude_aliasespropagate_to_loadersr/  rM  r1  r3  r4  zOptional[Type[Any]]"Optional[_InternalEntityType[Any]]z9Union[ColumnElement[bool], lambdas.DeferredLambdaElement]r   r0  r   r2  c           	     0   [        S[        R                  " US5      5      nUc  [        SU5      U l        S U l        OS U l        Xpl        X l        [        U5      (       ay  U R                  b  U R                  nOUc   eUR                  nSU l        [        R                  " U[        R                  [        U5      4[        R                  " US9S9U l        O1SU l        [        R                   " [        R                  U5      U l        X@l        XPl        g )NrV  Fr   T)track_closure_variables)lambda_argsopts)r   r8   r_  r/  rM  r2  callabler0  r?   DeferredLambdaElementr@   WhereHavingRoler  LambdaOptionsr1  r=   r  r3  r4  )	r   entity_or_baser1  loader_onlyr3  r4  r7  rM  wrap_entitys	            r   r?  LoaderCriteriaOption.__init__P  s    &~u5
 >#K@DDK#D K .N##+"..)))$mm+/D(")"?"?%%,[9;**,C	#D ,1D("+"2"2%%~#D  /$8!r   c                    [        UUUUS9$ )N)r3  r4  )r.  )r   rM  r1  r3  r4  s        r   	_unreduceLoaderCriteriaOption._unreduce  s     $+!5	
 	
r   c                    [         R                  U R                  (       a  U R                  R                  OU R                  U R
                  U R                  U R                  44$ r}   )r.  rC  rM  r!  r/  r2  r3  r4  r  s    r   
__reduce__LoaderCriteriaOption.__reduce__  sP     **&*kk""t7G7G%%$$))	
 	
r   c              #     #    U R                   (       a)  U R                   R                  R                   S h  vN   g U R                  (       d   e[	        U R                  R                  5       5      nU(       a  UR                  S5      n[        S[        R                  " USS95      nU(       a  UR                  R                   S h  vN   OUR                  UR                  5       5        U(       a  M~  g g  N N17f)Nr   rV  F)raiseerr)rM  r#  self_and_descendantsr/  list__subclasses__popr   r8   r_  extend)r   stacksubclassru  s       r   _all_mappers!LoaderCriteriaOption._all_mappers  s     ;;{{))>>>>####))88:;E 99Q<.&&x%@ "zz>>>>LL!8!8!:; %	 ? ?s(   5C>C:BC>
C<+C>8C><C>c                X    UR                   R                  R                  SS 5      U L a  gg)Nfor_loader_criteriaFT)select_statementrQ  rR  r   compile_states     r   _should_include$LoaderCriteriaOption._should_include  s3    **77;;%t 
 r   c                    U R                   (       a0  [        SU R                  R                  UR                  5      5      nOU R                  n[        U[        5      (       d   e[        R                  " USU 0SSS9$ )NColumnElement[bool]rT  T)detect_subquery_colsind_cols_on_fromclause)	r0  r   r1  _resolve_with_argsrM  r   rG   r  _deep_annotate)r   ext_infocrits      r   _resolve_where_criteria,LoaderCriteriaOption._resolve_where_criteria  sv     ''%##66xGD
 &&D$....&&"D)!%#'	
 	
r   c                &    U R                  U5        g r}   )process_compile_state)r   rW  mapper_entitiess      r   'process_compile_state_replaced_entities<LoaderCriteriaOption.process_compile_state_replaced_entities  s    
 	""=1r   c                :    U R                  UR                  5        g)z7Apply a modification to a given :class:`.CompileState`.N)get_global_criteriaglobal_attributesrV  s     r   re  *LoaderCriteriaOption.process_compile_state  s     	  !@!@Ar   c                ~    U R                  5        H)  nUR                  " SU4/ 5      nUR                  U 5        M+     g )Nadditional_entity_criteria)rQ  
setdefaultr   )r   r   r  load_criterias       r   rj  (LoaderCriteriaOption.get_global_criteria  s?    ##%B&11-r2BM   & &r   )r2  r0  rM  r3  r4  r/  r1  N)FFTT)r>  z_EntityType[Any]r1  zXUnion[_ColumnExpressionArgument[bool], Callable[[Any], _ColumnExpressionArgument[bool]]]r?  r   r3  r   r4  r   r7  r   )r   zIterator[Mapper[Any]])rW  rW   r   r   )r`  rV  r   r[  )rW  rW   rf  zIterable[_MapperEntity]r   r  )rW  rW   r   r  )r   zDict[Any, Any]r   r  )r   r   r   r   r   r   rA   r  dp_plain_objdp_has_cache_keyr  r  r  _traverse_internalsr   r?  r   rC  rF  rQ  rX  rb  rg  re  rj  r   r~   r   r   r.  r.  )  sZ   	I 
::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
/9 /9 /9 #/9 "&/9b 
 
	
<"
0
	
$2&2 12 
	2B'r   r.  c                    U R                   $ r}   )rf  )r  s    r   <lambda>rv    s
    &2F2Fr   c                     [        U 5      nUb  UR                  (       d  g UR                  nU$ ! [        R                   a     g f = fr}   )r*   	is_mappedr#  r   NO_STATE)r!  class_managerr#  s      r   _inspect_mcr{    sL    ,V4 (?(?%%  << s   0 0 AAc                B    [        S[        U 5      5      n[        U5      $ )Nr  )r   rN   r{  )r!  origins     r   _inspect_generic_aliasr~    s      *j01Fvr   c                  >   \ rS rSr% SrSr SrSrSrSr	\
R                  " 5       rS\S'   \
R                  rS\S'         SS	 jr      SS
 jr\SS j5       r\SS j5       r\  SS j5       rS\S'    S\S'    S rS r\S 5       rS r        SS jrSrg)Bundlei  a  A grouping of SQL expressions that are returned by a :class:`.Query`
under one namespace.

The :class:`.Bundle` essentially allows nesting of the tuple-based
results returned by a column-oriented :class:`_query.Query` object.
It also
is extensible via simple subclassing, where the primary capability
to override is that of how the set of expressions should be returned,
allowing post-processing as well as custom return types, without
involving ORM identity-mapped classes.

.. seealso::

    :ref:`bundles`


FTrc   _propagate_attrszList[_ColumnsClauseElement]exprsc           
        U=U l         U l        U Vs/ s H&  n[        R                  " [        R
                  X@S9PM(     nnXPl        [        S U Vs/ s H  ofR                  R                  SU5      PM      sn 5       5      R                  5       =U l        U l        UR                  SU R                  5      U l        gs  snf s  snf )a  Construct a new :class:`.Bundle`.

e.g.::

    bn = Bundle("mybundle", MyClass.x, MyClass.y)

    for row in session.query(bn).filter(bn.c.x == 5).filter(bn.c.y == 4):
        print(row.mybundle.x, row.mybundle.y)

:param name: name of the bundle.
:param \*exprs: columns or SQL expressions comprising the bundle.
:param single_entity=False: if True, rows for this :class:`.Bundle`
 can be returned as a "single entity" outside of any enclosing tuple
 in the same manner as a mapped entity.

)apply_propagate_attrsc              3  T   #    U  H  n[        US UR                  5      U4v   M      g7f)r   N)r}  _label)r  r   s     r   r  "Bundle.__init__.<locals>.<genexpr>A  s)      1
O S%,c2Os   &(bundlesingle_entityN)r   r  r=   r  r@   ColumnsClauseRoler  rD   rQ  rR  as_readonlyr   columnsrM  r  )r   r   r  r  r  coerced_exprses          r   r?  Bundle.__init__%  s    & #'&	DK
 	
  '' 	 	 
 #
 0 1
ANOA**8Q7O1
 !
 +-	  VVOT5G5GH
 Ps   -C %C
c           
         U R                   U R                  U R                  4[        U R                   Vs/ s H  o3R                  X5      PM     sn5      -   $ s  snf r}   )r   r   r  r  r  _gen_cache_key)r   rj   
bindparamsr  s       r   r  Bundle._gen_cache_keyG  sP     		4+=+=>CG::N:4  6:NB
 
 	
Ns   A
c                X    U R                   S   R                  R                  SS 5      nU$ )Nr   rP  r  rQ  rR  )r   r  s     r   r#  Bundle.mapperN  s,    $(JJqM$>$>$B$BD%
 	r   c                X    U R                   S   R                  R                  SS 5      nU$ )Nr   r  r  )r   ies     r   rM  Bundle.entityU  s-    152

,ss>40 	 	r   6ReadOnlyColumnCollection[str, KeyedColumnElement[Any]]c                    U R                   $ r}   )r   r  s    r   r  Bundle.entity_namespace\  s     vvr   r  r   c                    U R                   R                  U R                   5      nUR                  R                  U R                  5        U$ r}   )r   r   r{  r   )r   r  cloneds      r   _cloneBundle._clone  s5    ''7t}}-r   c           	        X S.nUR                   " U R                  5        U R                  S   R                  R	                  SU R
                  5      n[        R                  " U R                   Vs/ s H  o3R                  R	                  SU5      PM      sn[        R                  SS.6R                  U5      R                  SUS.5      $ s  snf )	N)r  r  r   r  r  F)_literal_as_text_rolegroupr  r  )r   rQ  r  r  rR  rM  r>   
ClauseListr@   r  r  r  )r   r   r  r  s       r   r  Bundle.__clause_element__  s    !%@4,,-A77;;dkk
 !! <@::F:a..$$Xq1:F ',&=&=
 Y{#!! -2&4	
 Gs   2%Cc                6    U R                  5       R                  $ r}   )r  clausesr  s    r   r  Bundle.clauses  s    &&(000r   c                2    U R                  5       nXl        U$ )z<Provide a copy of this :class:`.Bundle` passing a new label.)r  r   )r   r   r  s      r   r   Bundle.label  s     r   c                ^   ^^ [        X3 Vs/ s H  nSPM     sn5      mSUU4S jjnU$ s  snf )aw  Produce the "row processing" function for this :class:`.Bundle`.

May be overridden by subclasses to provide custom behaviors when
results are fetched. The method is passed the statement object and a
set of "row processor" functions at query execution time; these
processor functions when given a result row will return the individual
attribute value, which can then be adapted into any kind of return data
structure.

The example below illustrates replacing the usual :class:`.Row`
return structure with a straight Python dictionary::

    from sqlalchemy.orm import Bundle


    class DictBundle(Bundle):
        def create_row_processor(self, query, procs, labels):
            "Override create_row_processor to return values as dictionaries"

            def proc(row):
                return dict(zip(labels, (proc(row) for proc in procs)))

            return proc

A result from the above :class:`_orm.Bundle` will return dictionary
values::

    bn = DictBundle("mybundle", MyClass.data1, MyClass.data2)
    for row in session.execute(select(bn)).where(bn.c.data1 == "d1"):
        print(row.mybundle["data1"], row.mybundle["data2"])

r~   c                J   > T" T Vs/ s H
  o" U 5      PM     sn5      $ s  snf r}   r~   )r  prockeyed_tupleprocss     r   r  )Bundle.create_row_processor.<locals>.proc  s$    e<edS	e<==<s    )r  zRow[Any]r   r   r;   )r   queryr  labelslr  r  s     `   @r   create_row_processorBundle.create_row_processor  s8    L #6+?1B+?@	> 	>  ,@s   *
)r  r   r  r  r   r  N)r   r   r  z_ColumnExpressionArgument[Any]r  r   )rj   rj   r  zList[BindParameter[Any]]r   zTuple[Any, ...])r   zOptional[Mapper[Any]])r   r5  )r   r  )r  zSelect[Any]r  z#Sequence[Callable[[Row[Any]], Any]]r  zSequence[str]r   zCallable[[Row[Any]], Any])r   r   r   r   r   r  is_clause_element	is_mapperrF  	is_bundler:   immutabledictr  r   	EMPTY_SET	proxy_setr?  r  r  r#  rM  r  r  r  r  r   r  r   r~   r   r   r  r    s9   $ M< II,0,>,>,@)@I&& I I!? IGJ ID
 
.F
	
     	? 
 DC0 >=/

2 1 1++ 3+ 	+
 
#+r   r  z
Bundle[_T]c                6    [         R                  " U SS0U5      $ )zDeep copy the given ClauseElement, annotating each element with the
"_orm_adapt" flag.

Elements within the exclude collection will be cloned but not annotated.


_orm_adaptT)r  r_  )r  excludes     r   _orm_annotater    s     ""7\4,@'JJr   c                ,    [         R                  " U SS9$ )zRemove annotations that link a column to a particular mapping.

Note this doesn't affect "remote" and "foreign" annotations
passed by the :func:`_orm.foreign` and :func:`_orm.remote`
annotators.

)r  r  )r   r  _deep_deannotater  s    r   _orm_deannotater    s     $$6 r   c                .    [         R                  " U 5      $ r}   r  r  s    r   _orm_full_deannotater    s    $$W--r   c                      \ rS rSrSr\R                  R                  rSr      S
               SS jjr	S r
   S         SS jjr  S       SS jjrS	rg)_ORMJoini  z/Extend Join to support ORM constructs as input.TNc	           	        [        S[        R                  " U5      5      n	[        S[        R                  " U5      5      n
U
R                  nX`l        Xpl        [        U[        R                  5      (       ak  [        (       a+  [        UR                  [        R                  5      (       d   eUR                  R                  5       nUR                  nXR                  -  nO2[        U[         5      (       a  UnUR"                  R                  nOS nS nU	R                  nU(       a  [$        R&                  " X5      (       a  UnO[        U[(        5      (       d   eUnUR+                  UUSU
SUS9u  nnnnnnUb>  U(       a  [,        R.                  " UUU5      nUnO[,        R.                  " UUUU5      nUnOUnUU l        [3        U	5      (       a  UR4                  R7                  SS 5      nO%[9        U	5      (       d  [;        U	5      (       a  U	nOS nUb"  U R4                  R=                  SU05      U l        [?        U5      =(       a    U(       + n[@        RB                  RE                  XX#XE5        U RF                  c   eU(       a&  U =RF                  [,        RH                  " U6 -  sl#        U(       d  [K        U
SS 5      (       a  U
RL                  RN                  (       af  [        SU
5      n
U
RL                  RP                  nUb@  [;        U
5      (       a  U
RR                  RU                  U5      nU RF                  U-  U l#        g g g g g )Nz+Union[FromClause, _InternalEntityType[Any]]T)source_selectabledest_selectablesource_polymorphicof_type_entityalias_secondaryextra_criteriar  r#  rV  )+r   r8   r_  r@  
_left_memo_right_memor   r   QueryableAttributer   
comparatorr[   
Comparator_source_selectabler  _extra_criteriar1   parentr  clause_is_presentrI   _create_joinsr9   r   _target_adapterrB   rQ  rR  r   r   r  r   r>   Joinr?  r  and_r}  r#  single_single_table_criterionr  r  )r   leftrightr  isouterfullr  r  r  	left_info
right_infoadapt_toon_selectablepropleft_selectable
adapt_frompjsjsourcedest	secondarytarget_adapterr  augment_onclausesingle_crits                            r   r?  _ORMJoin.__init__  s    9t$
	
 9u%

 (( %&h
 = =>>}!'')=)H)H    %//BBDM$$D777O.11D KK22MD M#..))-II*
!/:>>>>,
 """, (#') $. #  ~HHYr:E!H88D)RAD!H#1D  ##*77;;L I&&*?	*J*J$LL# $ 1 1 7 7.!D  0=X  UgL}}(((MMSXX77M 
Hd33!!((8*EJ %++CCK&(44","5"5">">{"KK $ ; ' ) 4 r   c           	        Un[        U[        R                  5      (       a-  UR                  n[        U[        R                  5      (       a  M-  U R                  UL d   e[        U R                  UR                  U R                  U R                  U R                  UR                  R                  S9n[        UUR                  UR                  UR                  UR                  S9$ )z\Splice a join into the center.

Given join(a, b) and join(b, c), return join(a, b).join(c)

)r  r  r  )r  r  )r   r9   r  r  r  r  r  r  r  r  r  )r   r  leftmostr  s       r   _splice_into_center_ORMJoin._splice_into_centerr  s     388,,}}H 388,, zzX%%%IIJJMMLL((77
 KKNNMM))
 	
r   c                    [        XX$US9$ )N)r  r  r  )r   r  r  r  r  s        r   r   _ORMJoin.join  s     X'JJr   c                    [        XUSUS9$ )NT)r  r  r  )r   r  r  r  s       r   	outerjoin_ORMJoin.outerjoin  s     Xt$GGr   )rQ  r  r  r  r  )NFFNNr~   )r  ra   r  ra   r  Optional[_OnClauseArgument]r  r   r  r   r  Optional[Any]r  r  r  zTuple[ColumnElement[bool], ...])NFF)
r  ra   r  r  r  r   r  r   r   r  r   )r  ra   r  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3NM 15$(%);=w<!w< #w< .	w<
 w< w< "w< #w< 9w<r
@ 15K"K .K 	K
 K 
K 15	H"H .H 	H
 
H Hr   r  c                h   [        U[        5      (       a  [        R                  " S5      e[        U[        R
                  5      (       aX  UR                  (       a  UR                  nUR                  nUb  [        U5      (       d  [        R                  " SU 35      eUnOUnUR                  XS9$ )a  Create filtering criterion that relates this query's primary entity
to the given related instance, using established
:func:`_orm.relationship()`
configuration.

E.g.::

    stmt = select(Address).where(with_parent(some_user, User.addresses))

The SQL rendered is the same as that rendered when a lazy loader
would fire off from the given parent on that attribute, meaning
that the appropriate state is taken from the parent object in
Python without the need to render joins to the parent table
in the rendered statement.

The given property may also make use of :meth:`_orm.PropComparator.of_type`
to indicate the left side of the criteria::


    a1 = aliased(Address)
    a2 = aliased(Address)
    stmt = select(a1, a2).where(with_parent(u1, User.addresses.of_type(a2)))

The above use is equivalent to using the
:func:`_orm.with_parent.from_entity` argument::

    a1 = aliased(Address)
    a2 = aliased(Address)
    stmt = select(a1, a2).where(
        with_parent(u1, User.addresses, from_entity=a2)
    )

: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.

  .. versionadded:: 1.2

z@with_parent() accepts class-bound mapped attributes, not stringsz6Expected relationship property for with_parent(), got )from_entity)
r   r   r   r   r   r  _of_typer  r   _with_parent)r  r  r  mapper_propertyprop_ts        r   with_parentr    s    l $""N
 	
 
D*77	8	8==--K--"*>+
 +
 &&&')  !xAAr   c                F    [         R                  " U 5      nUR                  $ )zReturn True if the given object has a database
identity.

This typically corresponds to the object being
in either the persistent or detached state.

.. seealso::

    :func:`.was_deleted`

)r   instance_statehas_identityobject_r   s     r   r
  r
    s      %%g.Er   c                F    [         R                  " U 5      nUR                  $ )zReturn True if the given object was deleted
within a session flush.

This is regardless of whether or not the object is
persistent or detached.

.. seealso::

    :attr:`.InstanceState.was_deleted`

)r   r	  was_deletedr  s     r   r  r    s      %%g.Er   c                2   [        U5      (       a3  [        U 5      (       a"  UR                  5       U R                  5       L a  gg[        U 5      (       a"  U R                  (       a  XR                  ;   $ XL $ [	        U 5      (       d   eUR                  U 5      $ )zdetermine if 'given' corresponds to 'entity', in terms
of an entity passed to Query that would match the same entity
being referred to elsewhere in the query.

TF)r   r  r  rd  r   common_parentgivenrM  s     r   _entity_corresponds_tor    s     V$$ ''!!#u'8'8'::	u	%	%!!;;;;?"%    &&r   c                >   [        U 5      (       aB  [        U5      =(       a0    UR                  (       + =(       a    XL =(       d    XR                  ;   $ [        U5      (       d  U R                  UR                  5      $ UR                  =(       a    XR
                  ;   $ )aP  determine if 'given' corresponds to 'entity', in terms
of a path of loader options where a mapped attribute is taken to
be a member of a parent entity.

e.g.::

    someoption(A).someoption(A.b)  # -> fn(A, A) -> True
    someoption(A).someoption(C.d)  # -> fn(A, C) -> False

    a1 = aliased(A)
    someoption(a1).someoption(A.b)  # -> fn(a1, A) -> False
    someoption(a1).someoption(a1.b)  # -> fn(a1, a1) -> True

    wp = with_polymorphic(A, [A1, A2])
    someoption(wp).someoption(A1.foo)  # -> fn(wp, A1) -> False
    someoption(wp).someoption(wp.A1.foo)  # -> fn(wp, wp.A1) -> True

)r   r  rq  rS  r#  rd  r  s     r   $_entity_corresponds_to_use_path_implr  %  s    * U##!&) P+++PNF.N.N$N	

 #6**yy'' ## 9888	
r   c                   U R                   (       a0  XR                  ;   =(       d    U R                  R                  U5      $ U R                  (       a&  XR                  ;   =(       d    U R                  U5      $ U R                  U5      $ )z]determine if 'given' "is a" mapper, in terms of the given
would load rows of type 'mapper'.

)rF  rd  r#  rS  )r  r#  s     r   _entity_isar  I  sn    
 777 
5<<;K;K<
 	
 
	'	'777L599V;LLyy  r   c                   S n[        U[        5      (       a  [        R                  " U5      u  p4n[        U[        5      (       a  [        U[        5      (       a
  XC-
  S::  a  / $ [        U[        5      (       a  US:  d  [        U[        5      (       a  US:  a  U" 5         U R                  X45      nUb  [        U5      SSUR                  2   $ [        U5      $ US:X  a  U" 5         g[        XUS-    5      S   $ )z\calculate __getitem__ in terms of an iterable query object
that also has a slice() method.

c                     [        S5      e)Nz@negative indexes are not accepted by SQL index / slice operators)
IndexErrorr~   r   r   _no_negative_indexes&_getitem.<locals>._no_negative_indexes^  s    &
 	
r   r   Nr   )r   slicer:   decode_sliceintrK  step)iterable_queryitemr  startstopr!  ress          r   _getitemr'  X  s    
 $ --d3T tS!!5#&&!I$$tS!!dQh """5/9TD49945592: "dQh78;;r   c                p     [        XUR                  5      n[        U[        5      $ ! [         a     gf = fr   )rK   r   rO   r   	NameError)raw_annotationr   originating_cls	annotateds       r   _is_mapped_annotationr-    sC    
B+!;!;
	  	+@AA   s   ( 
55c                      \ rS rSrSrg)_CleanupErrori  r~   N)r   r   r   r   r   r~   r   r   r/  r/    s    r   r/  c           	     |  ^	 [         R                  " SU 5      nU(       d  U $  [        UR                  S5      U5      nU[        R                  L a  SnO% [        U[        5      (       a  UR                  nOU $ / nUn UR                  X'L a  UOUR                  S5      5        UR                  S5      n[         R                  " SU5      nUc  UR                  U5        OMe  [         R                  " SUS	   5      (       dt  [         R                  " S
US	   5      (       dU  Sm	SR                  U	4S jUS	   R                  S5       5       5      US	'   SR                  U5      S[!        U5      S-
  -  -   n U $ ! [         a'  n[        SU  SUR                  S5       S35      UeS nAff = f! [         a    U s $ f = f)Nz^([^ \|]+?)\[(.+)\]$r   zFor annotation "z%", could not resolve container type "z[".  Please ensure this type is imported at the module level outside of TYPE_CHECKING blocksClassVarr6   z^["'].*["']$r  z[\[\]]z"' r   c              3  N   >#    U  H  nS UR                  T5       S 3v   M     g7f)"N)strip)r  rT  
stripcharss     r   r  1_cleanup_mapped_str_annotation.<locals>.<genexpr>  s(      
6Jda

:&'q)6Js   "%r   [])r   matchrL   r  r)  r/  typingr1  
issubclassr   r   	TypeErrorr   searchr   r   len)
r   r   mmr   nereal_symbolrO  innerg2r5  s
            @r   _cleanup_mapped_str_annotationrD    s    
):	6BRXXa[*<= foo 	#455!ll!! EE
BK[U[[^D[[^0"5=LL . HH(%)44
 		)U2Y//
II 
6;Biooc6J
 
b	 XXe_s5zA~(>?
C  zl +!xx{m ,..

 	   		s/   E8 !F, 7F, 8
F)"F$$F),F;:F;c	           	        U c<  U(       a4  [         R                  " SUR                   SU SUR                   S35      eg [        UU U[        S9n	U(       a  U	S4$ [        U	S
5      (       a  [        U	[        5      (       d  U(       az  U(       d  g[        U	S
S5      nU[        R                  L a  g[        U[        5      (       a  [        U[         5      (       a  g[         R                  " SUR                   SU S3SS9eU	S4$ [#        U	R$                  5      S:w  a  [         R                  " S5      e['        U	R$                  S   5      U	R(                  4$ ! [
         a   n
[         R                  " SU  S35      U
eSn
A
f[         a5  nU(       a!  S	U ;   a  [         R                  " SU  S35      UeU n	 SnAGNkSnAff = f)zgiven an annotation, figure out if it's ``Mapped[something]`` and if
so, return the ``something`` part.

Includes error raise scenarios and other options.

Nz4Python typing annotation is required for attribute ".z " when primary argument(s) for "z#" construct are None or not present)rz   zCould not interpret annotation zt.  Check that it uses names that are correctly imported at the module level. See chained stack trace for more hints.zMapped[
__origin__zType 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)coder   z)Expected sub-type for Mapped[] annotationr   )orm_excMappedAnnotationErrorr   rK   rD  r/  r)  r  rO   r   r}  r:  r1  r   r  r;  r+   r>  __args__rM   rG  )r*  r   r   r   attr_clsrequiredis_dataclass_fieldexpect_mappedrI  r,  cer@  r}  s                r   _extract_mapped_subtyperR    s   $ //LL>3% (%%&&IK 
 # ,9	
	, $y,//7G,8
 8
  L$?V__,  --*M3 3  33+CLL>3% @- -   $ !$&y!!"a'//;  %Y%7%7%:;  
 	
}  ++-n-= >D D
 		
  #	^3//1.1A BH H 	 #	#s$   E 
G$E??G*F<<Gc                v    [        U S5      (       a  U R                  5       nOS n[        R                  " X5      $ )N_mapper_property_name)r  rT  r:   clsname_as_plain_name)r  r   s     r   _mapper_property_as_plain_namerV  ^	  s4    t,--))+%%d11r   )p_unionT)NN)r!  zOptional[Type[_T]]r"  zUnion[Any, Tuple[Any, ...]]r  zOptional[_T]r  z%Optional[Union[Row[Any], RowMapping]]r  r  r   z_IdentityKeyType[_T])r!  r  r   zOptional[Mapper[_O]]r}   )r  rd   r  r  r   rd   )r  rd   r   rd   )r  r'  r  z"attributes.QueryableAttribute[Any]r  zOptional[_EntityType[Any]]r   r[  )r  r'  r   r   )r  rV  rM  rV  r   r   )r  rV  r#  zMapper[Any]r   r   )r"  z
Query[Any]r#  r   r   r   )r*  rk   r   r   r+  r   r   r   )r   r   r   r   r   r   )TT)r*  zOptional[_AnnotationScanType]r   r  r   r   r   r   rM  r   rN  r   rO  r   rP  r   rI  r   r   z@Optional[Tuple[Union[_AnnotationScanType, str], Optional[type]]])r  r   r   r   )
__future__r   r'  	functoolsr   r   r:  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   rJ  _typingr   r   r   r   r  r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   
interfacesr0   r1   r2   r3   r4   path_registryr5   r7   r   r8   r9   r:   engine.resultr<   r=   r>   r?   r@   r  rA   sql._typingrB   sql.annotationrC   sql.baserD   sql.cache_keyrE   rF   sql.elementsrG   rH   sql.selectablerI   util.langhelpersrJ   util.typingrK   _de_stringify_annotationrL   _eval_name_onlyrM   rN   rO   rP   rQ   rR   rS   rT   rU   contextrV   rW   r#  rX   rY   r  rZ   relationshipsr[   enginer\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   sql.visitorsrj   rk   rl   	frozensetr   partialr  _de_stringify_partialrx   r   r   r   r   r  r$  Enumr&  ColumnAdapterr5  rE  InspectablerX  _self_inspectsrc  r  r.  	_inspectsr  r{  GenericAliasr~  r  r  r  r  r  r  r  r
  r  r  r  r  r'  r-  	Exceptionr/  rD  rR  rV  r~   r   r   <module>rv     s   #   	                           * # ) 6 ' * 2 ( 0 .  2 .  0 . &  < 4 ( ! & 8 , 2 ) 7      (     "  ' 5 ' ' / ( - ' , M ; 2 $ * ! "	$),$&(53#!721/1$3,6'+'1T	 ")).*	
	 	X 	 12JK 
@H @ m%:?%KLFYs^ FR?DF =AO3f "&)-UD "15$(UDUD&UD 	UD
 
/UD "UD UDp9+dii 9+x
(00 
:2P'' 2PjG',-/CB/GG'T I<r",-BKI< I<X* *8p'> p'f   \ "#F G d  DI l# $ Y<(Y YxK.lHz lHd /3IBIB
,IB ,IB 	IBX "'#'-E'	'.!
#!
-E!
	!
H!$<NB'B	B B 
	B*	I 	WW),WWD i
1i
	i
 i
 
	i

 i
 i
 i
 i
 i
 Fi
X2r   