
    ,h              
      "   S r SSKJ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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J.r.  S'S+K/J0r0  S'S,K/J1r1  S'S-K/J2r2  S'S.K3J4r4  S'S/K3J5r5  S'S0K6J7r7  S'S1K8J9r9  S'S2K:J;r;  S'S3K<J=r=  S'S4K.J>r>  S'S5K?J@r@  S'S6K?JArA  \R*                  (       a  SS7KBJCrC  SS8KBJDrD  SS9KBJErE  SS:KBJFrF  SS;KBJGrG  SS<KHJIrI  SS=KJJrJ  SS>KKJLrL  SS?KKJMrM  SS@KKJNrN  SSAKOJPrP  SSBKQJRrR  SSCKSJTrT  SSDKUJVrV  SSEKJWrW  SSFKXJYrY  SSGKZJ[r[  SSHK\J]r]  SSIK^J_r_  SSJK.J`r`  SSKK.Jara  S'SLKbJcrc  S'SMKdJere  S'SNKdJfrf  S'SOKdJgrg  S'SPKdJhrh  S'SQK8Jiri  S'SRKjJkrk  S'SSK?Jlrl  \\ST4   rm\" SU\SV9rn\" SW\SXSY9ro\" SZS[SV9rp " S\ S]\1R                  5      rr " S^ S_\1R                  \1R                  \n   5      ru " S` Sa\u\n   5      rv " Sb Sc\1R                  5      rx " Sd Se\A5      ry " Sf Sg5      rz " Sh Si\5      r{\{" \4R                  \4R                  \4R                  \4R                  \4R                  \4R                  \4R                  5      r}\{" Sj\4R                  \4R                  \4R                  \4R                  \4R                  \4R                  5      r~ " Sk Sl5      r " Sm Sn\\\n   5      r\-GR                   " So Sp\7\\\n   \"\.GR                  5      5       r\-GR                   " Sq Sr\*\o   \\o   \95      5       r " Ss St\\n   5      r " Su Sv\55      r " Sw Sx\7\5      r " Sy Sz\5      r " S{ S|\5      r " S} S~\5      r\.GR                  " SSSS9 " S S\5      5       r " S S5      rg)z

Contains various base classes used throughout the ORM.

Defines some key base classes prominent within the internals.

This module and the classes within are mostly private, though some attributes
are exposed when inspecting mappings.

    )annotationsN)Any)Callable)cast)ClassVar)Dict)Generic)Iterator)List)
NamedTuple)NoReturn)Optional)Sequence)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )exc)path_registry)_MappedAttribute)EXT_CONTINUE)EXT_SKIP)EXT_STOP)InspectionAttr)InspectionAttrInfo)
MANYTOMANY)	MANYTOONE)NO_KEY)NO_VALUE)NotExtension)	ONETOMANY)RelationshipDirection)SQLORMOperations   )ColumnElement)
inspection)util)	operators)roles)visitors)_NoArg)ExecutableOption)HasCacheKey)ColumnOperators)Column)
TypeEngine)warn_deprecated)RODescriptorReference)	TypedDict)_EntityType)_IdentityKeyType)_InstanceDict)_InternalEntityType)_ORMAdapterProto)InstrumentedAttribute)Mapped)_MapperEntity)ORMCompileState)QueryContext)RegistryType)_ClassScanMapperConfig)_PopulatorDict)Mapper)AbstractEntityRegistry)Query)Session)InstanceState)_LoadElement)AliasedInsp)
ORMAdapter)Result)_ColumnExpressionArgument)_ColumnsClauseArgument)_DMLColumnArgument)	_InfoType)OperatorType)_TraverseInternalsType)_AnnotationScanType._T)bound_T_coT)rU   	covariant_TLSType[LoaderStrategy]c                      \ rS rSrSrSrSrg)ORMStatementRoles    z?Executable SQL or text() construct, including ORM aware objectsN__name__
__module____qualname____firstlineno__	__slots__
_role_name__static_attributes__r]       Q/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/orm/interfaces.pyr[   r[   s   s    II rf   r[   c                      \ rS rSrSrSrSrg)ORMColumnsClauseRolez   r]   z7ORM mapped entity, aliased entity, or Column expressionNr^   r]   rf   rg   ri   ri   z   s     IJJrf   ri   c                      \ rS rSrSrSrSrg)ORMEntityColumnsClauseRole   r]   zORM mapped or aliased entityNr^   r]   rf   rg   rl   rl      s    I/Jrf   rl   c                      \ rS rSrSrSrSrg)ORMFromClauseRole   r]   z5ORM mapped entity, aliased entity, or FROM expressionNr^   r]   rf   rg   ro   ro      s    IHJrf   ro   c                  H    \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
\S'   Srg)ORMColumnDescription   strnamez!Union[Type[Any], TypeEngine[Any]]typeboolaliasedz_ColumnsClauseArgument[Any]exprz%Optional[_ColumnsClauseArgument[Any]]entityr]   N)r_   r`   ra   rb   __annotations__re   r]   rf   rg   rr   rr      s     
I ,+M
%%11rf   rr   c                  r    \ rS rSrSr\SS j5       rS	S jr                    S
S jrSS jr	Sr
g)_IntrospectsAnnotations   r]   c                    U R                   $ N)r_   )clss    rg   _mapper_property_name-_IntrospectsAnnotations._mapper_property_name   s    ||rf   c                >    [        SU R                  5       < S35      e)zjreturn a copy of this object to use in declarative when the
object is found inside of an Annotated object.zUse of the z> construct inside of an Annotated object is not yet supported.)NotImplementedErrorr   selfs    rg   found_in_pep593_annotated1_IntrospectsAnnotations.found_in_pep593_annotated   s.     "$4469 :L L
 	
rf   c
                    g)zaPerform class-specific initializaton at early declarative scanning
time.

.. versionadded:: 2.0

Nr]   )
r   	decl_scanregistryr   originating_modulekeymapped_container
annotationextracted_mapped_annotationis_dataclass_fields
             rg   declarative_scan(_IntrospectsAnnotations.declarative_scan       rf   c           	     r    [         R                  " SUR                   SU SU R                  5        S35      e)Nz4Python typing annotation is required for attribute ".z " when primary argument(s) for "z#" construct are None or not present)sa_excArgumentErrorr_   r   )r   r   r   s      rg   _raise_for_required+_IntrospectsAnnotations._raise_for_required   sG    ""~Qse $**,- .00
 	
rf   Nreturnrt   )r   r   )r   rB   r   rA   r   	Type[Any]r   Optional[str]r   rt   r   zOptional[Type[Mapped[Any]]]r   Optional[_AnnotationScanType]r   r   r   rw   r   None)r   rt   r   r   r   r   )r_   r`   ra   rb   rc   classmethodr   r   r   r   re   r]   rf   rg   r}   r}      s    I 
)  	
 *  6 2 &C ! 
&
rf   r}   c                      \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S\S
'   S\S'   S\S'   SS jr\          SS j5       rSr	g)_AttributeOptions   zdefine Python-local attribute behavior options common to all
:class:`.MapperProperty` objects.

Currently this includes dataclass-generation arguments.

.. versionadded:: 2.0

zUnion[_NoArg, bool]dataclasses_initdataclasses_reprzUnion[_NoArg, Any]dataclasses_defaultz Union[_NoArg, Callable[[], Any]]dataclasses_default_factorydataclasses_comparedataclasses_kw_onlyzUnion[_NoArg, bool, None]dataclasses_hashc                  ^ 0 nU R                   [        R                  La  U R                   US'   U R                  [        R                  La  U R                  US'   U R                  [        R                  La  U R                  US'   U R
                  [        R                  La  U R
                  US'   U R                  [        R                  La  U R                  US'   U R                  [        R                  La  U R                  US'   U R                  [        R                  La  U R                  US'   SU;   a$  [        US   5      (       a  [        SU< S	3S
5        SU;   aC  US   (       d9  SU;   a3  [        US   5      (       d   SU;  a  UR                  S5      mU4S jUS'   [        R                  " S0 UD6$ )z<Return a ``dataclasses.Field`` object given these arguments.default_factorydefaultinitreprcomparekw_onlyhashzBCallable object passed to the ``default`` parameter for attribute a   in a ORM-mapped Dataclasses context is ambiguous, and this use will raise an error in a future release.  If this callable is intended to produce Core level INSERT default values for an underlying ``Column``, use the ``mapped_column.insert_default`` parameter instead.  To establish this callable as providing a default value for instances of the dataclass itself, use the ``default_factory`` dataclasses parameter.z2.0c                    > T $ r   r]   )r   s   rg   <lambda>7_AttributeOptions._as_dataclass_field.<locals>.<lambda>   s    Grf   r]   )r   r.   NO_ARGr   r   r   r   r   r   callabler4   popdataclassesfield)r   r   kwr   s      @rg   _as_dataclass_field%_AttributeOptions._as_dataclass_field   s     ++6==@$($D$DB !##6==8 44ByM  5..BvJ  5..BvJ##6==8 44ByM##6==8 44ByM  5..BvJ?x966  G $=	=  bLvJRR	]++!+ ffY'G$3B !  &2&&rf   c                    [        U[        5      (       a  UR                  R                  U5      nXU4$ U[        R
                  La  XU4$ Ub   S5       eX4$ )zgiven attribute key, annotation, and value from a class, return
the argument tuple we would pass to dataclasses.make_dataclass()
for this attribute.

z/Mapped[] received without a mapping declaration)
isinstance_DCAttributeOptions_attribute_optionsr   r.   r   )r   r   r   r   elemdc_fields         rg   !_get_arguments_for_make_dataclass3_AttributeOptions._get_arguments_for_make_dataclass  si      d/00..BB3GHX..&T**) LKK5 $$rf   r]   N)r   rt   r   r   )
r   rt   r   rS   r   Optional[Any]r   rT   r   z_Union[Tuple[str, _AnnotationScanType], Tuple[str, _AnnotationScanType, dataclasses.Field[Any]]])
r_   r`   ra   rb   __doc__r{   r   r   r   re   r]   rf   rg   r   r      s}     *)))++!AA,,,,///'b %%%% (%% (	%%
 %%
%% %%rf   r   Fc                  4    \ rS rSr% SrSrS\S'    S\S'   Srg)	r   iB  a_  mixin for descriptors or configurational objects that include dataclass
field options.

This includes :class:`.MapperProperty`, :class:`._MapsColumn` within
the ORM, but also includes :class:`.AssociationProxy` within ext.
Can in theory be used for other descriptors that serve a similar role
as association proxy.   (*maybe* hybrids, not sure yet.)

r]   r   r   rw   _has_dataclass_argumentsN)r_   r`   ra   rb   r   rc   r{   re   r]   rf   rg   r   r   B  s!     I)) #"rf   r   c                  D    \ rS rSrSrSr\SS j5       r\SS j5       rSr	g)	_MapsColumnsiY  zinterface for declarative-capable construct that delivers one or more
Column objects to the declarative process to be part of a Table.
r]   c                    [        5       e)zAreturn a MapperProperty to be assigned to the declarative mappingr   r   s    rg   mapper_property_to_assign&_MapsColumns.mapper_property_to_assign`  s     "##rf   c                    [        5       e)zVA list of Column objects that should be declaratively added to the
new Table object.

r   r   s    rg   columns_to_assign_MapsColumns.columns_to_assigne  s     "##rf   N)r   zOptional[MapperProperty[_T]])r   zList[Tuple[Column[_T], int]])
r_   r`   ra   rb   r   rc   propertyr   r   re   r]   rf   rg   r   r   Y  s4     I$ $ $ $rf   r   c                     \ rS rSr% SrSrS\R                  R                  4S\R                  R                  4/r
S\S'   \(       d  SrS	r S
\S'    S\S'    S\S'    SrS\S'    S\S'    S\S'    S#S jr            S$S jr                S%S jr S&           S'S jjrS(S jrS)S jr  S*     S+S jjrS,S 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)0MapperPropertyiw  a  Represent a particular class attribute mapped by :class:`_orm.Mapper`.

The most common occurrences of :class:`.MapperProperty` are the
mapped :class:`_schema.Column`, which is represented in a mapping as
an instance of :class:`.ColumnProperty`,
and a reference to another class produced by :func:`_orm.relationship`,
represented in the mapping as an instance of
:class:`.Relationship`.

)_configure_started_configure_finishedr   r   parentr   infodocr   r   rR   _cache_key_traversalNTzPropComparator[_T]
comparatorrt   Mapper[Any]Frw   _links_to_entityr   r   rP   r   c                    0 $ )a  Info dictionary associated with the object, allowing user-defined
data to be associated with this :class:`.InspectionAttr`.

The dictionary is generated when first accessed.  Alternatively,
it can be specified as a constructor argument to the
:func:`.column_property`, :func:`_orm.relationship`, or
:func:`.composite`
functions.

.. seealso::

    :attr:`.QueryableAttribute.info`

    :attr:`.SchemaItem.info`

r]   r   s    rg   _memoized_attr_info"MapperProperty._memoized_attr_info  s	    " 	rf   c                    g)zCalled by Query for the purposes of constructing a SQL statement.

Each MapperProperty associated with the target mapper processes the
statement referenced by the query context, adding columns and/or
criterion as appropriate.

Nr]   )r   contextquery_entitypathadapterkwargss         rg   setupMapperProperty.setup  r   rf   c                    g)zSProduce row processing functions and append to the given
set of populators lists.

Nr]   )r   r   r   r   mapperresultr   
populatorss           rg   create_row_processor#MapperProperty.create_row_processor  r   rf   c                    [        S5      $ )af  Iterate through instances related to the given instance for
a particular 'cascade', starting with this MapperProperty.

Return an iterator3-tuples (instance, mapper, state).

Note that the 'cascade' collection on this MapperProperty is
checked first for the given type before cascade_iterator is called.

This method typically only applies to Relationship.

r]   )iter)r   type_statedict_visited_stateshalt_ons         rg   cascade_iteratorMapperProperty.cascade_iterator  s    , Bxrf   c                    Xl         g)zSet the parent mapper that references this MapperProperty.

This method is overridden by some subclasses to perform extra
setup when the mapper is first known.

N)r   )r   r   r   s      rg   
set_parentMapperProperty.set_parent  s	     rf   c                    g)a  Hook called by the Mapper to the property to initiate
instrumentation of the class attribute managed by this
MapperProperty.

The MapperProperty here will typically call out to the
attributes module to set up an InstrumentedAttribute.

This step is the first of two steps to set up an InstrumentedAttribute,
and is called early in the mapper setup process.

The second step is typically the init_class_attribute step,
called from StrategizedProperty via the post_instrument_class()
hook.  This step assigns additional state to the InstrumentedAttribute
(specifically the "impl") which has been determined after the
MapperProperty has determined what kind of persistence
management it needs to do (e.g. scalar, object, collection, etc).

Nr]   r   r   s     rg   instrument_classMapperProperty.instrument_class  r   rf   c                    SU l         SU l        U(       a  [        nO[        nU(       a  X:w  a  SU l        Xl        g SU l        X0l        g )NFT)r   r   #_DEFAULT_READONLY_ATTRIBUTE_OPTIONS_DEFAULT_ATTRIBUTE_OPTIONSr   r   )r   attribute_options_assume_readonly_dc_attributesdefault_attrss       rg   __init__MapperProperty.__init__1  sF    
 #(#( )?M6M!2!C,0D)&7#,1D)&3#rf   c                @    SU l         U R                  5         SU l        g)zCalled after all mappers are created to assemble
relationships between mappers and perform other post-mapper-creation
initialization steps.


TN)r   do_initr   r   s    rg   r   MapperProperty.initE  s     #'#' rf   c                V    [        U R                  R                  U R                  5      $ )a>  Return the class-bound descriptor corresponding to this
:class:`.MapperProperty`.

This is basically a ``getattr()`` call::

    return getattr(self.parent.class_, self.key)

I.e. if this :class:`.MapperProperty` were named ``addresses``,
and the class to which it is mapped is ``User``, this sequence
is possible::

    >>> from sqlalchemy import inspect
    >>> mapper = inspect(User)
    >>> addresses_property = mapper.attrs.addresses
    >>> addresses_property.class_attribute is User.addresses
    True
    >>> User.addresses.property is addresses_property
    True


)getattrr   class_r   r   s    rg   class_attributeMapperProperty.class_attributeP  s    0 t{{))48844rf   c                    g)zPerform subclass-specific initialization post-mapper-creation
steps.

This is a template method called by the ``MapperProperty``
object's init() method.

Nr]   r   s    rg   r  MapperProperty.do_initj  r   rf   c                    g)a  Perform instrumentation adjustments that need to occur
after init() has completed.

The given Mapper is the Mapper invoking the operation, which
may not be the same Mapper as self.parent in an inheritance
scenario; however, Mapper will always at least be a sub-mapper of
self.parent.

This method is typically used by StrategizedProperty, which delegates
it to LoaderStrategy.init_class_attribute() to perform final setup
on the class-bound InstrumentedAttribute.

Nr]   r   s     rg   post_instrument_class$MapperProperty.post_instrument_classs  r   rf   c	                    g)z_Merge the attribute represented by this ``MapperProperty``
from source to destination object.

Nr]   )	r   sessionsource_statesource_dict
dest_state	dest_dictload
_recursive_resolve_conflict_maps	            rg   mergeMapperProperty.merge  r   rf   c                b    SU R                   R                  [        U 5      [        U SS5      4-  $ )Nz<%s at 0x%x; %s>r   zno key)	__class__r_   idr  r   s    rg   __repr__MapperProperty.__repr__  s4    !NN##tHD%*%
 
 	
rf   )r   r   r   r   r   r   rP   r   r?   r   r>   r   rE   r   Optional[ORMAdapter]r   r   r   r   r   r?   r   r>   r   rE   r   r   r   Result[Any]r   r)  r   rC   r   r   r   )r   rt   r   InstanceState[Any]r   r9   r   zSet[InstanceState[Any]]r   z.Optional[Callable[[InstanceState[Any]], bool]]r   zGIterator[Tuple[object, Mapper[Any], InstanceState[Any], _InstanceDict]])r   r   r   rw   r   r   r   r   r   r   NF)r  zOptional[_AttributeOptions]r  rw   r   r   r   r   )r   zInstrumentedAttribute[_T])r  rG   r  r,  r  r9   r  r,  r  r9   r  rw   r  zDict[Any, object]r  z#Dict[_IdentityKeyType[Any], object]r   r   r   )r_   r`   ra   rb   r   rc   r-   ExtendedInternalTraversaldp_has_cache_key	dp_stringr   r{   r   cascadeis_property_is_relationshipr   r   r   r   r   r   r  r   r   r  r  r  r   r%  re   r]   rf   rg   r   r   w  s:   		I 
855FFG	22<<=40 
 K
 #"C 
H!6 
'
O &  $ %	
 &  
   $ %	
   & # 
* CG " 	
 0 @
0, :>/4464 )-4 
	4(	( 5 52 ) #	
 ' !  &  C 
 
rf   r   c                     \ rS rSr% SrSrSrS\S'   S\S'   S	\S
'    S     S S jjr\	R                  S!S j5       rS"S jr    S#S jr    S$S jr\	R                  S%S j5       r S     S&S jjr\	R                  S'S j5       r\	R                  S(S j5       r\S)S j5       r\S*S j5       r\S+S j5       r\" \R4                  \5      r\" \R4                  \5      r\" \R4                  \5      r\R>                  (       a          S,S jr         S,S jr!S-S jr"    S.S jr# S     S/S jjr$ S     S/S jjr%Sr&g)0PropComparatori  a  Defines SQL operations for ORM mapped attributes.

SQLAlchemy allows for operators to
be redefined at both the Core and ORM level.  :class:`.PropComparator`
is the base class of operator redefinition for ORM-level operations,
including those of :class:`.ColumnProperty`,
:class:`.Relationship`, and :class:`.Composite`.

User-defined subclasses of :class:`.PropComparator` may be created. The
built-in Python comparison and math operator methods, such as
:meth:`.operators.ColumnOperators.__eq__`,
:meth:`.operators.ColumnOperators.__lt__`, and
:meth:`.operators.ColumnOperators.__add__`, can be overridden to provide
new operator behavior. The custom :class:`.PropComparator` is passed to
the :class:`.MapperProperty` instance via the ``comparator_factory``
argument. In each case,
the appropriate subclass of :class:`.PropComparator` should be used::

    # definition of custom PropComparator subclasses

    from sqlalchemy.orm.properties import (
        ColumnProperty,
        Composite,
        Relationship,
    )


    class MyColumnComparator(ColumnProperty.Comparator):
        def __eq__(self, other):
            return self.__clause_element__() == other


    class MyRelationshipComparator(Relationship.Comparator):
        def any(self, expression):
            "define the 'any' operation"
            # ...


    class MyCompositeComparator(Composite.Comparator):
        def __gt__(self, other):
            "redefine the 'greater than' operation"

            return sql.and_(
                *[
                    a > b
                    for a, b in zip(
                        self.__clause_element__().clauses,
                        other.__composite_values__(),
                    )
                ]
            )


    # application of custom PropComparator subclasses

    from sqlalchemy.orm import column_property, relationship, composite
    from sqlalchemy import Column, String


    class SomeMappedClass(Base):
        some_column = column_property(
            Column("some_column", String),
            comparator_factory=MyColumnComparator,
        )

        some_relationship = relationship(
            SomeOtherClass, comparator_factory=MyRelationshipComparator
        )

        some_composite = composite(
            Column("a", String),
            Column("b", String),
            comparator_factory=MyCompositeComparator,
        )

Note that for column-level operator redefinition, it's usually
simpler to define the operators at the Core level, using the
:attr:`.TypeEngine.comparator_factory` attribute.  See
:ref:`types_operators` for more detail.

.. seealso::

    :class:`.ColumnProperty.Comparator`

    :class:`.Relationship.Comparator`

    :class:`.Composite.Comparator`

    :class:`.ColumnOperators`

    :ref:`types_operators`

    :attr:`.TypeEngine.comparator_factory`

prop_parententity_adapt_to_entityorm_prop_comparator_InternalEntityType[Any]r:  Optional[AliasedInsp[Any]]r;  z,RODescriptorReference[MapperProperty[_T_co]]r9  Nc                <    Xl         U=(       d    UU l        X0l        g r   r8  )r   r9  parentmapperadapt_to_entitys       rg   r  PropComparator.__init__  s     	,< /rf   c                    U R                   $ )zReturn the :class:`.MapperProperty` associated with this
:class:`.PropComparator`.


Return values here will commonly be instances of
:class:`.ColumnProperty` or :class:`.Relationship`.


)r9  r   s    rg   r   PropComparator.property  s     yyrf   c                    [        SU -  5      e)Nz%rr   r   s    rg   __clause_element__!PropComparator.__clause_element__  s    !$+..rf   c                <    [        SU R                  5       5      U4/$ )zReceive a SQL expression that represents a value in the SET
clause of an UPDATE statement.

Return a tuple that can be passed to a :class:`_expression.Update`
construct.

rO   )r   rF  )r   values     rg   _bulk_update_tuples"PropComparator._bulk_update_tuples  s#     *D,C,C,EFNOOrf   c                P    U R                  U R                  U R                  U5      $ )zzReturn a copy of this PropComparator which will use the given
:class:`.AliasedInsp` to produce corresponding expressions.
)r#  r9  r:  )r   rA  s     rg   rA  PropComparator.adapt_to_entity+  s!     ~~dii););_MMrf   c                .    U R                   R                  $ )zRlegacy; this is renamed to _parententity to be
compatible with QueryableAttribute.)r:  r   r   s    rg   _parentmapperPropComparator._parentmapper3  s     !!(((rf   c                P    U R                   R                  R                  " U40 UD6$ r   )r9  r   _criterion_existsr   	criterionr   s      rg   rR   PropComparator._criterion_exists9  s$    
 yy##55iJ6JJrf   c                J    U R                   c  gU R                   R                  $ )zbProduce a callable that adapts column expressions
to suit an aliased version of this comparator.

N)r;  _orm_adapt_elementr   s    rg   r   PropComparator.adapter@  s%       (((;;;rf   c                .    U R                   R                  $ r   )r9  r   r   s    rg   r   PropComparator.infoK  s    yy~~rf   c                (    U R                   " U40 UD6$ r   )any)abr   s      rg   _any_opPropComparator._any_opO  s    uuQ!&!!rf   c                (    U R                   " U40 UD6$ r   )has)leftotherr   s      rg   _has_opPropComparator._has_opS  s    xx(((rf   c                $    U R                  U5      $ r   )of_type)r]  r  s     rg   _of_type_opPropComparator._of_type_opW  s    yy  rf   c                    g r   r]   r   oprd  r   s       rg   operatePropComparator.operatea      !$rf   c                    g r   r]   rl  s       rg   reverse_operatePropComparator.reverse_operatee  rp  rf   c                B    U R                  [        R                  U5      $ )a5  Redefine this object in terms of a polymorphic subclass,
:func:`_orm.with_polymorphic` construct, or :func:`_orm.aliased`
construct.

Returns a new PropComparator from which further criterion can be
evaluated.

e.g.::

    query.join(Company.employees.of_type(Engineer)).filter(
        Engineer.name == "foo"
    )

:param \class_: a class or mapper indicating that criterion will be
    against this specific subclass.

.. seealso::

    :ref:`orm_queryguide_joining_relationships_aliased` - in the
    :ref:`queryguide_toplevel`

    :ref:`inheritance_of_type`

)rn  r7  
of_type_op)r   r  s     rg   rh  PropComparator.of_typei  s    4 ||N55v>>rf   c                D    U R                   " [        R                  /UQ76 $ )a  Add additional criteria to the ON clause that's represented by this
relationship attribute.

E.g.::


    stmt = select(User).join(
        User.addresses.and_(Address.email_address != "foo")
    )

    stmt = select(User).options(
        joinedload(User.addresses.and_(Address.email_address != "foo"))
    )

.. versionadded:: 1.4

.. seealso::

    :ref:`orm_queryguide_join_on_augmented`

    :ref:`loader_option_criteria`

    :func:`.with_loader_criteria`

)rn  r+   and_)r   criterias     rg   rx  PropComparator.and_  s    8 ||INN6X66rf   c                F    U R                   " [        R                  U40 UD6$ )a  Return a SQL expression representing true if this element
references a member which meets the given criterion.

The usual implementation of ``any()`` is
:meth:`.Relationship.Comparator.any`.

:param criterion: an optional ClauseElement formulated against the
  member class' table or attributes.

:param \**kwargs: key/value pairs corresponding to member class
  attribute names which will be compared via equality to the
  corresponding values.

)rn  r7  any_oprS  s      rg   r\  PropComparator.any       ( ||N119GGGrf   c                F    U R                   " [        R                  U40 UD6$ )a  Return a SQL expression representing true if this element
references a member which meets the given criterion.

The usual implementation of ``has()`` is
:meth:`.Relationship.Comparator.has`.

:param criterion: an optional ClauseElement formulated against the
  member class' table or attributes.

:param \**kwargs: key/value pairs corresponding to member class
  attribute names which will be compared via equality to the
  corresponding values.

)rn  r7  has_oprS  s      rg   rb  PropComparator.has  r~  rf   )r;  r:  r9  r   )r9  zMapperProperty[_T]r@  r=  rA  r>  )r   zMapperProperty[_T_co])r   zroles.ColumnsClauseRole)rI  r   r   z(Sequence[Tuple[_DMLColumnArgument, Any]])rA  zAliasedInsp[Any]r   PropComparator[_T_co])r   r   )rT  )Optional[_ColumnExpressionArgument[bool]]r   r   r   ColumnElement[Any])r   zOptional[_ORMAdapterProto]r'  )r]  r   r^  r   r   r   r   r   )rc  r   rd  r   r   r   r   r   )r]  r   r  r   r   r   )rm  rQ   rd  r   r   r   r   r  )r  z_EntityType[Any]r   r  )ry  z_ColumnExpressionArgument[bool]r   zPropComparator[bool])rT  r  r   r   r   zColumnElement[bool])'r_   r`   ra   rb   r   rc   __visit_name__r{   r  r*   non_memoized_propertyr   rF  rJ  rA  ro_non_memoized_propertyrO  rR  r   r   staticmethodr_  re  ri  r   r+   rQ   r|  r  ru  typingr   rn  rr  rh  rx  r\  rb  re   r]   rf   rg   r7  r7    sV   ^@ <I*N++00
66 7;	0 0 /0 4	0 

  
/PP	1PN/N	N 
"") #) @DK<K K 
	K 
""< #< 
"" # " " ) ) ! ! )(('2F)(('2Fi,,k:J	%"	%,/	%;>	%	%	%"	%+.	%:=	%	%?8787	7@ @DH<H H 
	H0 @DH<H H 
	H Hrf   r7  c                  :   \ rS rSr% SrSrSrS\S'   S\S'   S	\S
'   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S jrS S jr\R"                  " \5      rS\S'   \S!S j5       r\      S"S j5       rSrg)#StrategizedPropertyi  a`  A MapperProperty which uses selectable strategies to affect
loading behavior.

There is a single strategy selected by default.  Alternate
strategies can be selected at Query time through the usage of
``StrategizedOption`` objects via the Query.options() method.

The mechanics of StrategizedProperty are used for every Query
invocation for every mapped attribute participating in that Query,
to determine first how the attribute will be rendered in SQL
and secondly how the attribute will retrieve a value from a result
row and apply it to a mapped object.  The routines here are very
performance-critical.

)_strategiesstrategy_wildcard_token_default_path_loader_keystrategy_keyTzClassVar[str]strategy_wildcard_key_StrategyKeyr  z"Dict[_StrategyKey, LoaderStrategy]r  c                B    U R                    S[        R                   34$ )N:)r  r   _WILDCARD_TOKENr   s    rg   _memoized_attr__wildcard_token2StrategizedProperty._memoized_attr__wildcard_token  s(    ))*!M,I,I+JK
 	
rf   c                F    SU R                    S[        R                   344$ )Nloaderr  )r  r   _DEFAULT_TOKENr   s    rg   '_memoized_attr__default_path_loader_key;StrategizedProperty._memoized_attr__default_path_loader_key  s0     **+1]-I-I,JKM
 	
rf   c                    S nX    nUR                   UR                  UR                  4 H$  nXQR                  ;   d  M  UR                  U   n  U$    U$ r   )_loader_key_wildcard_path_loader_keyr  
attributes)r   r   r   r  search_pathpath_keys         rg   _get_context_loader'StrategizedProperty._get_context_loader  sh     (,j
 ##1100
H
 ---))(3 !
  rf   c                     U R                   U   $ ! [         a     Of = fU R                  " U /UQ76 nU" X5      =U R                   U'   nU$ r   )r  KeyError_strategy_lookup)r   r   r   r  s       rg   _get_strategy!StrategizedProperty._get_strategy  sa    	##C(( 		 ##D/3/ ,/t>9s    
c                    U R                  X5      nU(       a-  UR                  (       a  U R                  UR                  5      nOU R                  nUR                  " XX6U40 UD6  g r   )r  r  r  setup_query)r   r   r   r   r   r   r  strats           rg   r   StrategizedProperty.setup%  sW     ))'8foo&&v7EMME4	
<B	
rf   c           
         U R                  X5      nU(       a-  UR                  (       a  U R                  UR                  5      n	OU R                  n	U	R                  UUUUUUUU5        g r   )r  r  r  r   )
r   r   r   r   r   r   r   r   r  r  s
             rg   r   (StrategizedProperty.create_row_processor6  s`     ))'8foo&&v7EMME""		
rf   c                R    0 U l         U R                  U R                  5      U l        g r   )r  r  r  r  r   s    rg   r  StrategizedProperty.do_initP  s"    **4+<+<=rf   c                    U R                   R                  (       dG  UR                  R                  U R                  5      (       d  U R
                  R                  U5        g g g r   )r   non_primaryclass_manager_attr_has_implr   r  init_class_attributer   s     rg   r  )StrategizedProperty.post_instrument_classT  sG    ''((77AAMM..v6 B (rf   z\collections.defaultdict[Type[MapperProperty[Any]], Dict[_StrategyKey, Type[LoaderStrategy]]]_all_strategiesc                   ^ ^ SU U4S jjnU$ )Nc                   > SU R                   ;  a  / U l        [        [        TR	                  5       5      5      nU TR
                  T   U'   U R                  R                  U5        U $ )N_strategy_keys)__dict__r  tuplesorteditemsr  append)dec_clsr   r   r   s     rg   decorate2StrategizedProperty.strategy_for.<locals>.decoratea  s^      w'7'77)+&rxxz*+C,3C$S)""))#.Nrf   )r  rX   r   rX   r]   )r   r   r  s   `` rg   strategy_for StrategizedProperty.strategy_for_  s    	 	 rf   c                   UR                   R                    U R                   HJ  nX0R                  ;   d  M  [        (       a  [        U[        5      (       d   eU R                  U   n XB   s  $    U R                  R                  5        H  u  pVX&;   d  M  UnXb   n  O   S nS n[        R                  " U UUUU5      e! [         a     M  f = fr   )r   _with_polymorphic_mappers__mro__r  r   
issubclassr   r  r  orm_excLoaderStrategyException)	r   requesting_propertyr   prop_cls
strategiesproperty_typestratsintended_property_typeactual_strategys	            rg   r  $StrategizedProperty._strategy_lookupm  s     	""<<H... =%h???? 00:
%?* $ &)%8%8%>%>%@!M})6&"(+	 &A &*""O--"
 	
   s   )B??
CC)r  r  N)r   z
Tuple[str])r   zTuple[str, Tuple[str]])r   r?   r   rE   r   Optional[_LoadElement])r   r  r   LoaderStrategyr(  r*  r/  r-  )r   r   r   zCallable[[_TLS], _TLS])r  MapperProperty[Any]r   r   r   rY   )r_   r`   ra   rb   r   rc   inherit_cacher{   r  r  r  r  r   r   r  r  collectionsdefaultdictdictr  r   r  r  re   r]   rf   rg   r  r    sV    I M((33


	
&.D	6
 
 $
 %	

 &
 
 

"
 
 $
 %	

 
 
 &
 #
 

4>7 	%   &   
"5
=@
	
 
rf   r  c                  P    \ rS rSrSrSrSrSr SrSr	Sr
SrSr      SS jrSrg)	ORMOptioni  a  Base class for option objects that are passed to ORM queries.

These options may be consumed by :meth:`.Query.options`,
:meth:`.Select.options`, or in a more general sense by any
:meth:`.Executable.options` method.   They are interpreted at
statement compile time or execution time in modern use.  The
deprecated :class:`.MapperOption` is consumed at ORM query construction
time.

.. versionadded:: 1.4

r]   Fc                    Ub  U$ U $ )a  adapt this option to the "uncached" version of itself in a
loader strategy context.

given "self" which is an option from a cached query, as well as the
corresponding option from the uncached version of the same query,
return the option we should use in a new query, in the context of a
loader strategy being asked to load related rows on behalf of that
cached query, which is assumed to be building a new query based on
entities passed to us from the cached query.

Currently this routine chooses between "self" and "uncached" without
manufacturing anything new. If the option is itself a loader strategy
option which has a path, that path needs to match to the entities being
passed to us by the cached query, so the :class:`_orm.Load` subclass
overrides this to return "self". For all other options, we return the
uncached form which may have changing state, such as a
with_loader_criteria() option which will very often have new state.

This routine could in the future involve
generating a new option based on both inputs if use cases arise,
such as if with_loader_criteria() needed to match up to
``AliasedClass`` instances given in the parent query.

However, longer term it might be better to restructure things such that
``AliasedClass`` entities are always matched up on their cache key,
instead of identity, in things like paths and such, so that this whole
issue of "the uncached option does not match the entities" goes away.
However this would make ``PathRegistry`` more complicated and difficult
to debug as well as potentially less performant in that it would be
hashing enormous cache keys rather than a simple AliasedInsp. UNLESS,
we could get cache keys overall to be reliably hashed into something
like an md5 key.

.. versionadded:: 1.4.41

r]   )r   r   uncached_opts      rg   '_adapt_cached_option_to_uncached_option1ORMOption._adapt_cached_option_to_uncached_option  s    N #Krf   N)r   r@   r  r  r   r  )r_   r`   ra   rb   r   rc   _is_legacy_optionpropagate_to_loaders_is_core_is_user_defined_is_compile_state_is_criteria_option_is_strategy_optionr  re   r]   rf   rg   r  r    s[     I  H*#*3<*	*rf   r  c                  @    \ rS rSrSrSrSrSS jr      S	S jrSr	g)
CompileStateOptioni  a  base for :class:`.ORMOption` classes that affect the compilation of
a SQL query and therefore need to be part of the cache key.

.. note::  :class:`.CompileStateOption` is generally non-public and
   should not be used as a base class for user-defined options; instead,
   use :class:`.UserDefinedOption`, which is easier to use as it does not
   interact with ORM compilation internals or caching.

:class:`.CompileStateOption` defines an internal attribute
``_is_compile_state=True`` which has the effect of the ORM compilation
routines for SELECT and other statements will call upon these options when
a SQL string is being compiled. As such, these classes implement
:class:`.HasCacheKey` and need to provide robust ``_cache_key_traversal``
structures.

The :class:`.CompileStateOption` class is used to implement the ORM
:class:`.LoaderOption` and :class:`.CriteriaOption` classes.

.. versionadded:: 1.4.28


r]   Tc                    g)zApply a modification to a given :class:`.ORMCompileState`.

This method is part of the implementation of a particular
:class:`.CompileStateOption` and is only invoked internally
when an ORM query is compiled.

Nr]   )r   compile_states     rg   process_compile_state(CompileStateOption.process_compile_state  r   rf   c                    g)a9  Apply a modification to a given :class:`.ORMCompileState`,
given entities that were replaced by with_only_columns() or
with_entities().

This method is part of the implementation of a particular
:class:`.CompileStateOption` and is only invoked internally
when an ORM query is compiled.

.. versionadded:: 1.4.19

Nr]   r   r  mapper_entitiess      rg   'process_compile_state_replaced_entities:CompileStateOption.process_compile_state_replaced_entities  r   rf   N)r  r?   r   r   r  r?   r  zSequence[_MapperEntity]r   r   )
r_   r`   ra   rb   r   rc   r  r  r  re   r]   rf   rg   r  r    s:    . I& 1 
	rf   r  c                  2    \ rS rSrSrSr      SS jrSrg)LoaderOptioni  z`Describe a loader modification to an ORM statement at compilation time.

.. versionadded:: 1.4

r]   c                &    U R                  U5        g r   )r  r  s      rg   r  4LoaderOption.process_compile_state_replaced_entities  s    
 	""=1rf   Nr  )r_   r`   ra   rb   r   rc   r  re   r]   rf   rg   r  r    s/     I2&2 12 
	2rf   r  c                  *    \ rS rSrSrSrSrSS jrSrg)CriteriaOptioni'  zhDescribe a WHERE criteria modification to an ORM statement at
compilation time.

.. versionadded:: 1.4

r]   Tc                    g)zOupdate additional entity criteria options in the given
attributes dictionary.

Nr]   )r   r  s     rg   get_global_criteria"CriteriaOption.get_global_criteria3  r   rf   N)r  zDict[str, Any]r   r   )	r_   r`   ra   rb   r   rc   r  r  re   r]   rf   rg   r  r  '  s     Irf   r  c                  8    \ rS rSrSrSrSrSrSr SS	S jjr	Sr
g)
UserDefinedOptioni:  zvBase class for a user-defined option that can be consumed from the
:meth:`.SessionEvents.do_orm_execute` event hook.

payloadFTNc                    Xl         g r   r  )r   r   s     rg   r  UserDefinedOption.__init__M  s    rf   r   )r   r   )r_   r`   ra   rb   r   rc   r  r  r  r  re   r]   rf   rg   r  r  :  s/    
 I  rf   r  z1.4aK  The :class:`.MapperOption class is deprecated and will be removed in a future release.   For modifications to queries on a per-execution basis, use the :class:`.UserDefinedOption` class to establish state within a :class:`.Query` or other Core statement, then use the :meth:`.SessionEvents.before_orm_execute` hook to consume them.)constructorc                  :    \ rS rSrSrSrSrSr S	S jrS	S jr	Sr
g)
MapperOptioniQ  z"Describe a modification to a Queryr]   TFc                    g)z8Apply a modification to the given :class:`_query.Query`.Nr]   r   querys     rg   process_queryMapperOption.process_queryi  r   rf   c                &    U R                  U5        g)a?  same as process_query(), except that this option may not
apply to the given query.

This is typically applied during a lazy load or scalar refresh
operation to propagate options stated in the original Query to the
new Query being used for the load.  It occurs for those options that
specify propagate_to_loaders=True.

N)r	  r  s     rg   process_query_conditionally(MapperOption.process_query_conditionallyl  s     	5!rf   N)r  z
Query[Any]r   r   )r_   r`   ra   rb   r   rc   r  r  r	  r  re   r]   rf   rg   r  r  Q  s(     -I G"rf   r  c                      \ rS rSr% SrSrS\S'       SS jrSS jr              SS jr	                  SS	 jr
SS
 jrSrg)r  iz  a  Describe the loading behavior of a StrategizedProperty object.

The ``LoaderStrategy`` interacts with the querying process in three
ways:

* it controls the configuration of the ``InstrumentedAttribute``
  placed on a class to handle the behavior of the attribute.  this
  may involve setting up class-level callable functions to fire
  off a select operation when the attribute is first accessed
  (i.e. a lazy load)

* it processes the ``QueryContext`` at statement construction time,
  where it can modify the SQL statement that is being produced.
  For example, simple column attributes will add their represented
  column to the list of selected columns, a joined eager loader
  may establish join clauses to add to the statement.

* It produces "row processor" functions at result fetching time.
  These "row processor" functions populate a particular attribute
  on a particular mapped instance.

)parent_propertyis_class_levelr   r   r  strategy_optszClassVar[List[_StrategyKey]]r  c                    Xl         SU l        U R                   R                  U l        U R                   R                  U l        X l        [        U5      U l        g r.  )r  r  r   r   r  r  r  )r   r   r  s      rg   r  LoaderStrategy.__init__  sK      &#**11''++(!,/rf   c                    g r   r]   r   s     rg   r  #LoaderStrategy.init_class_attribute  s    rf   c                    g)zEstablish column and other state for a given QueryContext.

This method fulfills the contract specified by MapperProperty.setup().

StrategizedProperty delegates its setup() method
directly to this method.

Nr]   )r   r  r   r   loadoptr   r   s          rg   r  LoaderStrategy.setup_query  r   rf   c	                    g)zEstablish row processing functions for a given QueryContext.

This method fulfills the contract specified by
MapperProperty.create_row_processor().

StrategizedProperty delegates its create_row_processor() method
directly to this method.

Nr]   )	r   r   r   r   r  r   r   r   r   s	            rg   r   #LoaderStrategy.create_row_processor  r   rf   c                ,    [        U R                  5      $ r   )rt   r  r   s    rg   __str__LoaderStrategy.__str__  s    4''((rf   )r  r   r   r  r  r  N)r   r  r  r  r-  )r  r?   r   r>   r   rE   r  r  r   r)  r   r   r   r   )r   r?   r   r>   r   rE   r  r  r   r   r   r+  r   r)  r   rC   r   r   r   )r_   r`   ra   rb   r   rc   r{   r  r  r  r   r  re   r]   rf   rg   r  r  z  s    .I 100)09E0& $ %	
 ( &  
$  $ %	
 (   & # 
*)rf   r  )r   
__future__r   r  r   r  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r    r   r  r   baser   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r(   r   r)   r*   sqlr+   r,   r-   sql.baser.   r/   sql.cache_keyr0   sql.operatorsr1   
sql.schemar2   sql.type_apir3   r4   util.typingr5   r6   _typingr7   r8   r9   r:   r;   r  r<   r=   r   r>   r?   r@   decl_apirA   	decl_baserB   loadingrC   r   rD   rE   r  rF   r  rG   r   rH   strategy_optionsrI   rJ   rK   engine.resultrL   sql._typingrM   rN   rO   rP   rQ   sql.visitorsrR   rS   r  rT   rV   rX   StatementRoler[   ColumnsClauseRoleTypedColumnsClauseRoleri   rl   StrictFromClauseRolero   rr   r}   r   r   r  r  r   r   _self_inspectsMemoizedSlotsr   r7  r  r  r  r  r  r  deprecated_clsr  r  r]   rf   rg   <module>r7     se  	 #                         6 . & & 2 : * ( " & . ( @ "         ' ' +  % " / #	$)&,)1&(%&1'5 $.! &740',51S#XTsd3v34u** K	U99"=K0!5b!9 0
I22 I
29 2)
 )
Xi%
 i%X /
MM
MM
MM
MM
MM
MM
MM  '8	
MM
MM
MM
MM
MM
MM' ## #.$&(8(< $< _
R_
 _
D	 rH%e,geno rH rHj	|
., |
~M  M`4i 4n2% 2"' &	 . 	F 	"9 "	">X) X)rf   