
    f                   	   d Z ddlmZ ddlZddlmZ ddlZddlZddlZddl	Z	ddl
Z
ddl
mZ ddl
mZ ddl
mZ ddl
mZ dd	l
mZ dd
l
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddlZddlm Z  ddlm!Z! ddl"m#Z# ddl"m$Z$ ddl%m&Z& ddl%m'Z' ddl%m(Z( dd l%m)Z) dd!l%m*Z* dd"l%m+Z+ dd#l%m,Z, dd$l%m-Z- dd%l.m/Z/ dd&l.m0Z0 dd'l.m1Z1 dd(l.m2Z2 dd)l.m3Z3 dd*l.m4Z4 dd+l.m5Z5 dd,l.m6Z6 dd-l7m8Z8 dd.l7m9Z9 dd/l7m:Z: d0d1lm;Z< d0d2lm=Z= d0d3lm>Z> d0d4lm?Z? d0d5lm@Z@ d0d6lm7Z7 d0d7lAmZ d0d8l@mBZB d0d9l@mCZC d0d:l@mDZD d0d;l@mEZE d0d<l@mFZF d0d=lGmHZH d0d>lGmIZI d0d?lJmKZK d0d@lLmMZM d0dAlLmNZN d0dBlOmPZP d0dClOmQZQ d0dDlOmRZR d0dElOmSZS d0dFlOmTZT d0dGlOmUZU d0dHlOmVZV d0dIlOmWZW d0dJlXmYZY d0dKlXmZZZ d0dLlXm[Z[ e
j                  rddMl"m]Z] ddNl"m^Z^ ddOl"m_Z_ ddPl"m`Z` ddQl"maZa ddRl"mbZb ddSl"mcZc ddTl%mdZd ddUlemfZf ddVlemgZg ddWlhmiZi ddXljmkZk ddYllmmZm ddZlnmoZo dd[lpmqZq dd\lrmsZs dd]ltmuZu dd^l7mvZv dd_l7mwZw d0d`lGmxZx d0dalGmyZy d0dblGmzZz d0dclJm{Z{ d0ddlJm|Z| d0delLm}Z} d0dflLm~Z~ d0dglLmZ d0dhlmZ d0dilmZ d0djlXmZ d0dklXmZ  edlem      Z ednem      Z edoem      Z edpem      Z edqem      Zeeee   eg ee   f   drdseg drf   eg dsf   f   ZeZdt   ZeeeHe   f   Zedueeg duf   f   ZeeZdv   eeHe   eg eHe   f   eg eeHe      f   eeeeHe   f      f   Zeeeeeeef   f   f   ZeeMe   eIe   eEj&                  dwf   Zeeee   eg ee   f   eg ef   ef   Z edxeHe   m      Z edydzm      ZeeeNe   eNe   f      ZeeeNe   eNe   f      ZeeeNe   eNe   f      Zdd{Zdd|Zej:                   G d} d~eeef                ZeeZdv   eeNe   df   f   Z G d de      Ze>jB                   G d de0e6e   e>jD                               ZddZ G d d      Z G d d      Z edd      Z edd      Z G d dee   e&e         Z G d dee   e-e   e)e         Zy)a
  Heuristics related to join conditions as used in
:func:`_orm.relationship`.

Provides the :class:`.JoinCondition` object, which encapsulates
SQL annotation and aliasing behavior focused on the `primaryjoin`
and `secondaryjoin` aspects of :func:`_orm.relationship`.

    )annotationsN)abc)Any)Callable)cast)
Collection)Dict)	FrozenSet)Generic)Iterable)Iterator)List)
NamedTuple)NoReturn)Optional)Sequence)Set)Tuple)Type)TypeVar)Union   )
attributes)strategy_options)insp_is_aliased_class)is_has_collection_adapter)_DeclarativeMapped)_is_mapped_class)class_mapper)DynamicMapped)LoaderCallableStatus)PassiveFlag)	state_str)WriteOnlyMapped)_AttributeOptions)_IntrospectsAnnotations)
MANYTOMANY)	MANYTOONE)	ONETOMANY)PropComparator)RelationshipDirection)StrategizedProperty)_orm_annotate)_orm_deannotate)CascadeOptions   )exc)Exists)log)schema)sql)util)inspect)	coercions)
expression)	operators)roles)visitors)_ColumnExpressionArgument)_HasClauseElement)_safe_annotate)ColumnClause)ColumnElement_deep_annotate)_deep_deannotate)_shallow_annotate)adapt_criterion_to_null)ClauseAdapter)join_condition)selectables_overlapvisit_binary_product)de_optionalize_union_types)Literal)resolve_name_to_real_class_name)_EntityType)_ExternalEntityType)_IdentityKeyType)_InstanceDict)_InternalEntityType)_O)_RegistryType)Mapped)_class_resolver)_ModNS)_ClassScanMapperConfig)DependencyProcessor)Mapper)Query)Session)InstanceState)
LazyLoader)AliasedClass)AliasedInsp)_CoreAdapterProto)_EquivalentColumnMap)	_InfoType)_AnnotationDict)SupportsAnnotations)BinaryExpression)BindParameter)ClauseElement)Table)
FromClause)_AnnotationScanType)RODescriptorReference_T)bound_T1_T2_PT_PT2
Mapper[_T]zAliasedClass[_T])selectjoinedselectinsubqueryraiseraise_on_sqlnoload	immediate
write_onlydynamicTFNrk   FzMapped[Any]_CEA_CEColumnElement[Any]c                b    t        t        j                  t        j                  |       ddi      S )a  Annotate a portion of a primaryjoin expression
    with a 'remote' annotation.

    See the section :ref:`relationship_custom_foreign` for a
    description of use.

    .. seealso::

        :ref:`relationship_custom_foreign`

        :func:`.foreign`

    remoteT_annotate_columnsr8   expectr;   ColumnArgumentRoleexprs    ]/var/www/highground/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/relationships.pyr   r      s.     11488T:J     c                b    t        t        j                  t        j                  |       ddi      S )a  Annotate a portion of a primaryjoin expression
    with a 'foreign' annotation.

    See the section :ref:`relationship_custom_foreign` for a
    description of use.

    .. seealso::

        :ref:`relationship_custom_foreign`

        :func:`.remote`

    foreignTr   r   s    r   r   r      s.     11489d:K r   c                  L    e Zd ZU dZdZded<   ded<   ded<   dd	Z	 	 	 	 dd
Zy)_RelationshipArgztstores a user-defined parameter value that must be resolved and
    parsed later at mapper configuration time.

    )nameargumentresolvedstrr   rp   r   zOptional[_T2]r   c                    | j                   d uS N)r   selfs    r   _is_populatedz_RelationshipArg._is_populated  s    }}D((r   c                    | j                   }t        |t              r!  ||| j                  dk(               | _        y t        |      rt        |      s |       | _        y || _        y )N	secondary)r   
isinstancer   r   r   callabler   )r   clsregistry_resolver
attr_values      r   _resolve_against_registryz*_RelationshipArg._resolve_against_registry  s]     ]]
j#&0DII4 DM j!*::*F&LDM&DMr   Nreturnbool)r   &Callable[[str, bool], _class_resolver]r   None)__name__
__module____qualname____doc__	__slots____annotations__r   r    r   r   r   r      s8    
 /I
IM)'$J'	'r   r   .c                  N    e Zd ZU dZded<   ded<   ded<   ded<   d	ed
<   d	ed<   y)_RelationshipArgszWstores user-passed parameters that are resolved at mapper configuration
    time.

    zP_RelationshipArg[Optional[_RelationshipSecondaryArgument], Optional[FromClause]]r   z\_RelationshipArg[Optional[_RelationshipJoinConditionArgument], Optional[ColumnElement[Any]]]primaryjoinsecondaryjoinz>_RelationshipArg[_ORMOrderByArgument, _RelationshipOrderByArg]order_byzN_RelationshipArg[Optional[_ORMColCollectionArgument], Set[ColumnElement[Any]]]foreign_keysremote_sideN)r   r   r   r   r   r   r   r   r   r     sB    
    ML  r   r   c            $          e Zd ZU dZej
                  ZdZ	 dZdZ	de
d<   de
d<    eddddd      Zd	Zd
e
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   de
d<   d e
d!<   d"e
d#<   	 	 dQd	d	d	d	d	dd	d	dd$dd	d%ddddd	d	d	d	ddd	dd	d	d	d	d	ddd	dd&"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dR fd'ZdSd(ZdTd)Z G d* d+ej$                  ee         Z	 	 dU	 	 	 	 	 	 	 dVd,Z	 	 	 dW	 	 	 	 	 	 	 	 	 dXd-Z	 	 	 	 	 	 	 	 	 	 dYd.Z	 	 dZ	 	 	 	 	 d[d/Zd\d0Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d]d1Zej:                  f	 	 	 	 	 	 	 	 	 d^d2Z	 d_	 	 	 	 	 	 	 	 	 	 	 d`d3Ze dad4       Z!e"	 	 	 	 	 	 dbd5       Z#dcd6Z$ejJ                  ddd7       Z&ejJ                  ded8       Z'df fd9Z(dfd:Z)dfd;Z*	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dgd<Z+ ejX                  d=      d_dhd>       Z-dfd?Z.e 	 	 did@       Z/e 	 	 djdA       Z0ejJ                   ejX                  dB      	 	 dkdC              Z1dfdDZ2e dldE       Z3e3jh                  dmdF       Z3dndGZ5dodHZ6dpdIZ7dqdJZ8dfdKZ9 ejX                  dL      dfdM       Z:ejJ                  dadN       Z;ejJ                  dadO       Z<	 	 	 	 	 	 dr	 	 	 	 	 	 	 	 	 	 	 	 	 dsdPZ= xZ>S )tRelationshipPropertyzDescribes an object property that holds a single item or list
    of items that correspond to a related database table.

    Public constructor is the :func:`_orm.relationship` function.

    .. seealso::

        :ref:`relationship_config_toplevel`

    TzSequence[str]	_overlapsr_   _lazy_strategyFpassive_deletespassive_updatesenable_typechecksactive_historycascade_backrefsNzOptional[DependencyProcessor]_dependency_processorColumnElement[bool]r   Optional[ColumnElement[bool]]r   Optional[FromClause]r   JoinCondition_join_condition_RelationshipOrderByArgr   Set[ColumnElement[Any]]_user_defined_foreign_keys_calculated_foreign_keysr   local_columns_ColumnPairssynchronize_pairsOptional[_ColumnPairs]secondary_synchronize_pairslocal_remote_pairsr+   	directionr   
_init_argszsave-update, mergeru   )"uselistcollection_classr   r   back_populatesr   backrefoverlapspost_updatecascadeviewonlyattribute_optionslazyr   r   r   r   r   r   
join_depthcomparator_factorysingle_parent	innerjoindistinct_target_keyload_on_pendingquery_classinfo	omit_joinsync_backrefdocbake_queriesr   _local_remote_pairs_legacy_inactive_history_stylec       "        p   t         %|   |       || _        || _        t	        t        d|d       t        d|d       t        d|d       t        d|d       t        d|d       t        d|d             | _        || _        || _        |r| j                  |||||"       |r|rt        j                  d	      || _        || _        || _        || _        || _        |"rt        j                  d
      || _        || _        || _        || _        || _        | | _        || _        |$| _        || _        |rt5        j6                  d       || _        |#| _        || _        |xs t>        j@                  | _!        t5        jD                  |        || jF                  jI                  |       d| j                  ff| _%        tM               | _'        |
r%tM        tQ        jR                  d|
            | _*        nd| _*        || _+        || _,        | jX                  r|	rt        j                  d      d | _-        y |	| _-        y )N)r   r   r   r   r   r   r   r   z-sync_backref and viewonly cannot both be TruezSThe 'cascade_backrefs' parameter passed to relationship() may only be set to False.zsetting omit_join to True is not supported; selectin loading of this relationship may not work correctly if this flag is set explicitly.  omit_join optimization is automatically detected for conditions under which it is supported.r   z\s*,\s*r   zCbackref and back_populates keyword arguments are mutually exclusive).super__init__r   r   r   r   r   r   r    _warn_for_persistence_only_flagssa_excArgumentErrorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r6   warnr   r   r   r   
Comparatorr   set_creation_orderr   updatestrategy_keyset_reverse_propertyresplitr   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	__class__s&                                        r   r   zRelationshipProperty.__init__n  sG   X 	+<= +[)T:]K>_mTBZ48^\4@]K>
 ' 11 / /"3-!1 2  &&?  )	* 0.&&; 
  /!2&"#6 ,.L+$II #"5.A"6"A"A 	 	%IIT"$dii02AD *h!?@DNDN ,**-   DL"DLr   c                    |j                         D ]1  \  }}|| j                  |   k7  st        j                  d|d       3 y )NzSetting z on relationship() while also setting viewonly=True does not make sense, as a viewonly=True relationship does not perform persistence operations. This configuration may raise an error in a future release.)items_persistence_onlyr6   r   )r   kwkvs       r   r   z5RelationshipProperty._warn_for_persistence_only_flags  sF    HHJ 	DAqD**1-- 		
 /0	2	r   c                    t        j                  |j                  | j                  | j	                  | |      || j
                         y )N)
comparatorparententityr   )r   register_descriptorclass_keyr   r   r   mappers     r   instrument_classz%RelationshipProperty.instrument_class
  s8    &&MMHH..tV<	
r   c                  6   e Zd ZU dZdZded<   ded<   	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 dd	Zd
ed<   	 ded<   	 d dZd!dZ	d"dZ
d#dZd$dZ	 	 	 	 d%dZd&dZdZd'dZ	 d(	 	 	 	 	 d)dZ	 d(	 	 	 	 	 d*dZ	 d(	 	 	 	 	 d*dZ	 	 	 	 	 	 d+dZ	 	 	 	 d'dZd'dZd,dZy)-RelationshipProperty.Comparatora  Produce boolean, comparison, and other operators for
        :class:`.RelationshipProperty` attributes.

        See the documentation for :class:`.PropComparator` for a brief
        overview of ORM level operator definition.

        .. seealso::

            :class:`.PropComparator`

            :class:`.ColumnProperty.Comparator`

            :class:`.ColumnOperators`

            :ref:`types_operators`

            :attr:`.TypeEngine.comparator_factory`

        )entityr  property_of_type_extra_criteriaz0RODescriptorReference[RelationshipProperty[_PT]]propOptional[_EntityType[_PT]]r
  Nc                l    || _         || _        || _        |r|| _        || _        yd| _        || _        y)zConstruction of :class:`.RelationshipProperty.Comparator`
            is internal to the ORM's attribute mechanics.

            N)r  _parententity_adapt_to_entityr
  r  )r   r  parentmapperadapt_to_entityof_typeextra_criterias         r   r   z(RelationshipProperty.Comparator.__init__3  s@     DI!-D$3D! ' $2D  !%#1D r   c                h    | j                  | j                  | j                  || j                        S )N)r  r  )r   r  r  r
  )r   r  s     r   r  z/RelationshipProperty.Comparator.adapt_to_entityH  s4     >>		"" /	 "  r   _InternalEntityType[_PT]r  Mapper[_PT]r  c                p    | j                   rt        | j                         S | j                  j                  S r   )r
  r7   r  r  r   s    r   _memoized_attr_entityz5RelationshipProperty.Comparator._memoized_attr_entityg  s(    }}t}}--yy'''r   c                .    | j                   j                  S r   r  r  r   s    r   _memoized_attr_mapperz5RelationshipProperty.Comparator._memoized_attr_mapperm  s    ;;%%%r   c                    | j                   r| j                   j                  S | j                  j                  j                  S r   )r  
selectabler	  parent_with_polymorphic_selectabler   s    r   _source_selectablez2RelationshipProperty.Comparator._source_selectablep  s3    $$,,777}}++HHHr   c                    | j                         }| j                  rt        | j                        }nd }| j                  j	                  |d|d| j
                        \  }}}}}}|||z  S |S )NT)source_selectablesource_polymorphicof_type_entityalias_secondaryr  )r!  r
  r7   r  _create_joinsr  )	r   
adapt_fromr%  pjsjsourcedestr   target_adapters	            r   __clause_element__z2RelationshipProperty.Comparator.__clause_element__v  s    002J}}!(!7!% 		''",#'- $#33 (  ~Bw	r   c                    t         j                  | j                  | j                  | j                  || j
                        S )zRedefine this object in terms of a polymorphic subclass.

            See :meth:`.PropComparator.of_type` for an example.


            r  r  r  )r   r   r  r  r  r  )r   r  s     r   r  z'RelationshipProperty.Comparator.of_type  sA     (22		"" $ 5 5#33 3  r   c                    t        d t        j                  |      D              }t        j	                  | j
                  | j                  | j                  | j                  | j                  |z         S )zAdd AND criteria.

            See :meth:`.PropComparator.and_` for an example.

            .. versionadded:: 1.4

            c              3  d   K   | ](  }t        j                  t        j                  |       * y wr   )r8   r   r;   WhereHavingRole).0clauses     r   	<genexpr>z7RelationshipProperty.Comparator.and_.<locals>.<genexpr>  s+         !6!6?s   .0r0  )
tupler6   coerce_generator_argr   r   r  r  r  r
  r  )r   criteriaexprss      r   and_z$RelationshipProperty.Comparator.and_  sn      "77A E
 (22		"" $ 5 5#33e; 3  r   c                    t        d      )zProduce an IN clause - this is not implemented
            for :func:`_orm.relationship`-based attributes at this time.

            zvin_() not yet supported for relationships.  For a simple many-to-one, use in_() against the set of foreign key values.)NotImplementedErrorr   others     r   in_z#RelationshipProperty.Comparator.in_  s    
 &1 r   c                   |t        |t        j                        rc| j                  j                  t
        t        fv r| j                          S t        | j                  j                  d| j                              S | j                  j                  rt        j                  d      t        | j                  j                  || j                              S )a  Implement the ``==`` operator.

            In a many-to-one context, such as::

              MyClass.some_prop == <some object>

            this will typically produce a
            clause such as::

              mytable.related_id == <some id>

            Where ``<some id>`` is the primary key of the given
            object.

            The ``==`` operator provides partial functionality for non-
            many-to-one comparisons:

            * Comparisons against collections are not supported.
              Use :meth:`~.Relationship.Comparator.contains`.
            * Compared to a scalar one-to-many, will produce a
              clause that compares the target columns in the parent to
              the given target.
            * Compared to a scalar many-to-many, an alias
              of the association table will be rendered as
              well, forming a natural join that is part of the
              main body of the query. This will not work for
              queries that go beyond simple AND conjunctions of
              comparisons, such as those which use OR. Use
              explicit joins, outerjoins, or
              :meth:`~.Relationship.Comparator.has` for
              more comprehensive non-many-to-one scalar
              membership tests.
            * Comparisons against ``None`` given in a one-to-many
              or many-to-many context produce a NOT EXISTS clause.

            Nadapt_source]Can't compare a collection to an object or collection; use contains() to test for membership.)r   r9   Nullr	  r   r)   r'   _criterion_existsr-   _optimized_compareadapterr   r   InvalidRequestErrorr>  s     r   __eq__z&RelationshipProperty.Comparator.__eq__  s    J }
5*// B==**y*.EE 22444(88 t|| 9  
 &&00= 
 %MM44DLL 5  r   c                   |$t        j                  t        j                  |      nd }t	        | dd       r~t        | j                        }|J |j                  |j                  |j                  }}}| j                  j                  r|s|j                         }|j                  }||||z  }n|}nd}d }| j                  r| j                         }	nd }	| j                  j!                  ||	      \  }
}}}}}|D ]<  }t	        | j                  j                  j"                  |      ||   k(  }||}8||z  }> |t%        |
      |z  }n!t%        |
| j                  j&                        }||r|s|j)                  |      }||j+                  ddi      }|t,        j.                  j1                  |      z  }|Ft-        j2                  d      j5                  |      j7                  ||      j9                  ||      }|S t-        j2                  d      j5                  |      j7                  |      j9                  |      }|S )Nr
  F)dest_selectabler#  )excludeno_replacement_traverseTr   )r8   r   r;   r3  getattrr7   r
  r  r  is_aliased_classr	  _is_self_referential_anonymous_fromclause_single_table_criterionrH  r!  r'  r  r-   r   traverse	_annotater5   True__ifnoneexistswhereselect_fromcorrelate_except)r   	criterionkwargswhere_criteriar   target_mapperto_selectablerP  single_critr#  r)  r*  r+  r,  r   r-  r   critjexs                       r   rF  z1RelationshipProperty.Comparator._criterion_exists  sb    (   !6!6	B  tZ.;BMM< '''KKOO)) /?}
 ==55>N$1$G$G$IM+CC*%1)4~)E)4#(  $||$($;$;$=!$(! ++ -"3 ,   ;t}}33::A>&)K!)%)N%3d%:N; ~!"%*!"dmm.G.GH *"( "0!8!8!H )!/!9!9.5" syy((88D$JJqMU4[ [y1%%dI6	  I JJqMU4[ [&%%d+	  Ir   c                ~    | j                   j                  st        j                  d       | j                  |fi |S )aS  Produce an expression that tests a collection against
            particular criterion, using EXISTS.

            An expression like::

                session.query(MyClass).filter(
                    MyClass.somereference.any(SomeRelated.x==2)
                )


            Will produce a query like::

                SELECT * FROM my_table WHERE
                EXISTS (SELECT 1 FROM related WHERE related.my_id=my_table.id
                AND related.x=2)

            Because :meth:`~.Relationship.Comparator.any` uses
            a correlated subquery, its performance is not nearly as
            good when compared against large target tables as that of
            using a join.

            :meth:`~.Relationship.Comparator.any` is particularly
            useful for testing for empty collections::

                session.query(MyClass).filter(
                    ~MyClass.somereference.any()
                )

            will produce::

                SELECT * FROM my_table WHERE
                NOT (EXISTS (SELECT 1 FROM related WHERE
                related.my_id=my_table.id))

            :meth:`~.Relationship.Comparator.any` is only
            valid for collections, i.e. a :func:`_orm.relationship`
            that has ``uselist=True``.  For scalar references,
            use :meth:`~.Relationship.Comparator.has`.

            z9'any()' not implemented for scalar attributes. Use has().r	  r   r   rI  rF  r   r\  r]  s      r   anyz#RelationshipProperty.Comparator.anye  sD    Z ==((00- 
 *4)))>v>>r   c                ~    | j                   j                  rt        j                  d       | j                  |fi |S )a  Produce an expression that tests a scalar reference against
            particular criterion, using EXISTS.

            An expression like::

                session.query(MyClass).filter(
                    MyClass.somereference.has(SomeRelated.x==2)
                )


            Will produce a query like::

                SELECT * FROM my_table WHERE
                EXISTS (SELECT 1 FROM related WHERE
                related.id==my_table.related_id AND related.x=2)

            Because :meth:`~.Relationship.Comparator.has` uses
            a correlated subquery, its performance is not nearly as
            good when compared against large target tables as that of
            using a join.

            :meth:`~.Relationship.Comparator.has` is only
            valid for scalar references, i.e. a :func:`_orm.relationship`
            that has ``uselist=False``.  For collection references,
            use :meth:`~.Relationship.Comparator.any`.

            z3'has()' not implemented for collections. Use any().rf  rg  s      r   hasz#RelationshipProperty.Comparator.has  sB    @ }}$$00I  *4)))>v>>r   c                   | j                   j                  st        j                  d      | j                   j	                  || j
                        }| j                   j                  | j                  |      |_        |S )a	  Return a simple expression that tests a collection for
            containment of a particular item.

            :meth:`~.Relationship.Comparator.contains` is
            only valid for a collection, i.e. a
            :func:`_orm.relationship` that implements
            one-to-many or many-to-many with ``uselist=True``.

            When used in a simple one-to-many context, an
            expression like::

                MyClass.contains(other)

            Produces a clause like::

                mytable.id == <some id>

            Where ``<some id>`` is the value of the foreign key
            attribute on ``other`` which refers to the primary
            key of its parent object. From this it follows that
            :meth:`~.Relationship.Comparator.contains` is
            very useful when used with simple one-to-many
            operations.

            For many-to-many operations, the behavior of
            :meth:`~.Relationship.Comparator.contains`
            has more caveats. The association table will be
            rendered in the statement, producing an "implicit"
            join, that is, includes multiple tables in the FROM
            clause which are equated in the WHERE clause::

                query(MyClass).filter(MyClass.contains(other))

            Produces a query like::

                SELECT * FROM my_table, my_association_table AS
                my_association_table_1 WHERE
                my_table.id = my_association_table_1.parent_id
                AND my_association_table_1.child_id = <some id>

            Where ``<some id>`` would be the primary key of
            ``other``. From the above, it is clear that
            :meth:`~.Relationship.Comparator.contains`
            will **not** work with many-to-many collections when
            used in queries that move beyond simple AND
            conjunctions, such as multiple
            :meth:`~.Relationship.Comparator.contains`
            expressions joined by OR. In such cases subqueries or
            explicit "outer joins" will need to be used instead.
            See :meth:`~.Relationship.Comparator.any` for
            a less-performant alternative using EXISTS, or refer
            to :meth:`_query.Query.outerjoin`
            as well as :ref:`orm_queryguide_joins`
            for more details on constructing outer joins.

            kwargs may be ignored by this operator but are required for API
            conformance.
            z9'contains' not implemented for scalar attributes.  Use ==rB  )	r  r   r   rI  rG  rH  r   '_Comparator__negated_contains_or_equalsnegation_clause)r   r?  r]  r5  s       r   containsz(RelationshipProperty.Comparator.contains  s}    z 99$$00* 
 YY11DLL 2 F yy&&2)-)J)J*& Mr   c                     j                   j                  t        k(  rt        j                  |      }	 	 	 	 	 	 	 	 d fd}d fd} j
                  j                  rmt        j                   j
                  j                  D cg c];  \  }}t        j                   ||       | ||      ||      k7   ||      d k(        = c}} S t        j                  t         j
                  j                  j                   j
                  j                  j                  |            D cg c]
  \  }}||k(   c}} } j                  |       S c c}}w c c}}w )Nc                    |j                   }t        j                  | j                  | j                  dj
                  j                  j
                  j                  |||            S )NT)type_unique	callable_)dictr5   	bindparamr  typer  _get_attr_w_warn_on_noner  )	local_colstate
remote_coldict_r   s       r   state_bindparamzURelationshipProperty.Comparator.__negated_contains_or_equals.<locals>.state_bindparam  sU    
 "JJE==!'nn#"&))"D"D II,,eUJ#	 r   c                B    j                   rj                  |       S | S r   )rH  )colr   s    r   adaptzKRelationshipProperty.Comparator.__negated_contains_or_equals.<locals>.adapt#  s    ||#||C00"
r   )rx  r   ry  InstanceState[Any]rz  r   r   BindParameter[Any])r~  r   r   r   )r  r   r(   r   instance_stater	  _use_getr5   r;  r   or_zipr  primary_keyprimary_key_from_instancerF  )r   r?  ry  r|  r  xyr\  s   `       r   __negated_contains_or_equalsz<RelationshipProperty.Comparator.__negated_contains_or_equals  sO    yy""i/"11%81- !3 (	# ==))88 +/--*J*J !'A  GG %a#258UA#F!G %aD 0	 	  #&,,88,,FFuM#A FI **9555)s   A E
*E
c                   |t        |t        j                        r^| j                  j                  t
        k(  r1t        | j                  j                  d| j                               S | j                         S | j                  j                  rt        j                  d      t        | j                  |            S )a  Implement the ``!=`` operator.

            In a many-to-one context, such as::

              MyClass.some_prop != <some object>

            This will typically produce a clause such as::

              mytable.related_id != <some id>

            Where ``<some id>`` is the primary key of the
            given object.

            The ``!=`` operator provides partial functionality for non-
            many-to-one comparisons:

            * Comparisons against collections are not supported.
              Use
              :meth:`~.Relationship.Comparator.contains`
              in conjunction with :func:`_expression.not_`.
            * Compared to a scalar one-to-many, will produce a
              clause that compares the target columns in the parent to
              the given target.
            * Compared to a scalar many-to-many, an alias
              of the association table will be rendered as
              well, forming a natural join that is part of the
              main body of the query. This will not work for
              queries that go beyond simple AND conjunctions of
              comparisons, such as those which use OR. Use
              explicit joins, outerjoins, or
              :meth:`~.Relationship.Comparator.has` in
              conjunction with :func:`_expression.not_` for
              more comprehensive non-many-to-one scalar
              membership tests.
            * Comparisons against ``None`` given in a one-to-many
              or many-to-many context produce an EXISTS clause.

            NrB  rD  )r   r9   rE  r	  r   r(   r-   rG  rH  rF  r   r   rI  rl  r>  s     r   __ne__z&RelationshipProperty.Comparator.__ne__A  s    N }
5*// B==**i7(99 t|| :     1133&&009  %T%F%Fu%MNNr   c                b    | j                   j                  j                          | j                   S r   )r  r  _check_configurer   s    r   _memoized_attr_propertyz7RelationshipProperty.Comparator._memoized_attr_property{  s"    II--/99r   )NNr   )
r  RelationshipProperty[_PT]r  z_InternalEntityType[Any]r  zOptional[AliasedInsp[Any]]r  r  r  Tuple[ColumnElement[bool], ...])r  zAliasedInsp[Any]r   z$RelationshipProperty.Comparator[Any])r   r  )r   r  )r   rk   r   r   )r  z_EntityType[Any]r   zPropComparator[_PT])r9  z_ColumnExpressionArgument[bool]r   zPropComparator[Any])r?  r   r   r   )r?  r   r   r   r   )r\  )Optional[_ColumnExpressionArgument[bool]]r]  r   r   r2   )r\  r  r]  r   r   r   )r?  z_ColumnExpressionArgument[Any]r]  r   r   r   )r   r  )r   r   r   r   r   r   r   r  r  r  r!  r.  r  r;  r@  __hash__rJ  rF  rh  rj  rn  rl  r  r  r   r   r   r   r    s   	(
	 ?>,, ;?26>@	2+	2 3	2 8		2
 0	2 <	2*	#3	1	 )(		 		(	&	I	4		<	 	.
	 8	x DHd	@d	 d	 	d	P DH3	?@3	? 3	? !	3	?n DH$	?@$	? $	? !	$	?LL	7L	CFL	 L	\1	61	6 1	6f8	Ot	r   r   c                    |J d }|0t        |      }|J t        |      r|j                  j                  }| j	                  |d||      S )NT)value_is_parentrC  r&  )r7   r   _adapteradapt_clauserG  )r   instancer&  from_entityrC  insps         r   _with_parentz!RelationshipProperty._with_parent  sl     ###48"7>{7KD###$T*#}}99&& %+	 ' 
 	
r   c                   	
 3	 t              t        dd      st        j                  d z        | } j                  ||      S |s. j                  j                   j                  j                  c}n- j                  j                   j                  j                  c}|r j                  
n j                  
t        j                  j                               	d	
 fd} j                   4|r2t#         j                   j%                               j'                  |      }t)        j*                  |i d|i      }|r ||      }|S # t        j                  $ r d Y aw xY w)Nis_instanceFzMapped instance expected for relationship comparison to object.   Classes, queries and other SQL elements are not accepted in this context; for comparison with a subquery, use %s.has(**criteria).rB  ru  c                p    | j                   v r'j                  | j                            | _        y y r   )_identifying_keyrw  r   )ru  bind_to_colr{  r  r   ry  s    r   visit_bindparamz@RelationshipProperty._optimized_compare.<locals>.visit_bindparam  s@    ))[8%)%B%B	 : :;	&	" 9r   )ru  r  r   r   )r7   r   NoInspectionAvailablerO  r   _lazy_none_clauser   
_lazywhere_bind_to_col_rev_lazywhere_rev_bind_to_colr  r  r   instance_dictobjr   rG   rR  rT  r<   cloned_traverse)r   ry  r  rC  r&  reverse_directionr\  r  r  r{  r  s   ``      @@@r   rG  z'RelationshipProperty._optimized_compare  s     }GE=%$H**. 15	5  !0/=))! *   !##..##00 #I{ ##22##44 #I{
 [[F[[F((5	 	 >>%/%446hy!  ,,rK9
	 $Y/Iq // s   E E65E6c                    j                        j                  j                         j                  dfd}|S )aK  Create the callable that is used in a many-to-one expression.

        E.g.::

            u1 = s.query(User).get(5)

            expr = Address.user == u1

        Above, the SQL should be "address.user_id = 5". The callable
        returned by this method produces the value "5" based on the identity
        of ``u1``.

        c                    J j                      x} }| t        j                  u}j                  		j                  rt
        j                  n t
        j                  t
        j                  z        }|t        j                  u r'|s`t        j                  ddt        	      d      |t        j                  u r'|s't        j                  ddt        	      d      |}|t        j                  dz         |S )NpassivezCan't resolve value for column z on object z'; no value has been set for this columnz2; the object is detached and the value was expiredzGot None for value of column %s; this is unsupported for a relationship comparison and will not currently produce an IS comparison (but may in a future release))r  r!   NO_VALUE_get_state_attr_by_column
persistentr"   PASSIVE_OFFPASSIVE_NO_FETCHINIT_OK	NEVER_SETr   rI  r#   PASSIVE_NO_RESULTr6   r   )

last_known	to_returnexisting_is_availablecurrent_valuecolumnr{  	lkv_fixedr  r  ry  s
       r   _goz:RelationshipProperty._get_attr_w_warn_on_none.<locals>._go  s    (((%.txx%88J"6"?"?? " #<< ''  ++$558K8KK = 	M  4 > >>, 44 "9U#35 
 "6"H"HH, 44 &,Yu-=?  *	 		4 7== r   )r   r   )get_property_by_column_track_last_known_valuer  _last_known_values)r   r  ry  r{  r  r  r  r  s    ```` @@r   rw  z-RelationshipProperty._get_attr_w_warn_on_none  sG    b ,,V4
 	%%dhh/,,	-	 -	^ 
r   c                    |s-| j                   j                  | j                   j                  }}n,| j                   j                  | j                   j                  }}t        ||      }|r ||      }|S r   )r   r  r  r  r  rF   )r   r  rC  r\  r  s        r   r  z&RelationshipProperty._lazy_none_clauseB  st    
 !##..##00 #I ##22##44 #I
 ,I{C	$Y/Ir   c                t    t        | j                  j                  j                        dz   | j                  z   S )N.)r   r  r  r   r  r   s    r   __str__zRelationshipProperty.__str__X  s+    4;;%%../#5@@r   c	                   |r| j                   D ]
  }	||	f|v s
 y  d| j                  vry | j                  |vry | j                  r|j	                  | j                        }
t        |
      sJ |
j                  ||      }|
j                  r|j                  rJ 	 |r;|j	                  | j                        j                  ||t        j                         g }|D ]]  }t        j                  |      }t        j                  |      }d||| f<   |j                  |||||      }|M|j!                  |       _ |s:t        j"                  ||| j                        }|D ]  }|j%                  |        y |j	                  | j                        }t        |      sJ |j'                  |||dt        j                         y || j                     }|Ht        j                  |      }t        j                  |      }d||| f<   |j                  |||||      }nd }|s||| j                  <   y |j	                  | j                        j'                  |||d        y )NmergeTr  )load
_recursive_resolve_conflict_mapF)_adaptr  )r   _cascader  r   get_implr   get_collection
collectionemptygetr"   PASSIVE_MERGEr   r  r  _mergeappendinit_state_collectionappend_without_eventr   )r   sessionsource_statesource_dict
dest_state	dest_dictr  r  r  rimplinstances_iterable	dest_listcurrentcurrent_statecurrent_dictr  collc	dest_impls                       r   r  zRelationshipProperty.merge[  s    ++  !$
2 $--'88;&<<((2D,T222!%!4!4\;!O
 48??)//LL ##DHH-11	;3L3L 2  I- * * 9 9' B)77@48
M401nn! )*? %  ?$$S)* !77	488 # 1A--a01 '//9	0;;; '55   "$((+G" * 9 9' B)77@48
M401nn! )*? %  &)	$((###DHH-11	3r   c                H   |j                   |   j                  }|j                  |||      }|t        j                  u s|g S t        |      r8|j                  ||||      D cg c]  }t        j                  |      |f c}S t        j                  |      |fgS c c}w )zReturn a list of tuples (state, obj) for the given
        key.

        returns an empty list if the value is None/empty/PASSIVE_NO_RESULT
        r  )	managerr  r  r!   r  r   r  r   r  )r   ry  r{  r  r  r  r  os           r   _value_as_iterablez'RelationshipProperty._value_as_iterable  s     }}S!&&HHUE7H3$666!)I&t, ,,UE1g,N **1-q1 
  ..q11566s   &Bc           
   #  ,  K   |dk7  s| j                   rt        j                  }n!t        j                  t        j                  z  }|dk(  r4|j
                  | j                     j                  j                  ||      }n| j                  ||| j                  |      }|dk(  xr d| j                  v}|D ]  \  }	}
|	|v r|
|	J t        j                  |
      }|r	 ||	      r2|r|	j                  sA|	j
                  j                  }|j                  | j                  j                  j                        s=t!        d| j                  d| j"                  j$                  d|
j&                  d	      |j)                  |	       |
||	|f  y w)
Ndeletezsave-updater  zrefresh-expiredelete-orphanzAttribute 'z' on class 'z"' doesn't handle objects of type '')r   r"   PASSIVE_NO_INITIALIZEr  NO_RAISEr  r  r  get_all_pendingr  r  r   r  r  isaclass_managerAssertionErrorr  r  r   add)r   rq  ry  r{  visited_stateshalt_onr  tuplesskip_pendingr  r  r  instance_mappers                r   cascade_iteratorz%RelationshipProperty.cascade_iterator  s     H 4 4!77G!--0D0DDGM!]]488,11AA%OF,,udhh - F
 %%N/*N 	 "(  	DNA/y
 !---&44Q7M7>2N$6$6,44;;O"&&t{{'@'@'G'GH$ xx!3!3Q[[B  ~._nmCCA 	Ds   FFc                8    | j                   ry| j                  duS )NF)r   r   r   s    r   _effective_sync_backrefz,RelationshipProperty._effective_sync_backref  s    ==$$E11r   c                    | j                   r(|j                  rt        j                  d|d| d      | j                   r$|j                   s|j                  durd|_        y y y y )NRelationship z( cannot specify sync_backref=True since z includes viewonly=True.F)r   r   r   rI  )rel_arel_bs     r   _check_sync_backrefz(RelationshipProperty._check_sync_backref  se     >>e00,,-2E; 
 NNNN""%/!&E 0 # r   c           
        | j                   j                  |d      }t        |t              st	        j
                  d| d|d      | j                  | |       | j                  ||        | j                  j                  |       |j                  j                  |        |j                          |j                   j                  | j                        s+t	        j                  d|d| d|d	| j                        |j                  r[| j                  t        t         fv rB| j                  |j                  k(  r(t	        j                  |d
| d| j                  d      y y y )NF)_configure_mappersz back_populates on relationship 'z' refers to attribute 'z{' that is not a relationship.  The back_populates parameter should refer to the name of a relationship on the target class.zreverse_property z on relationship z references relationship z", which does not reference mapper z and back-reference z  are both of the same direction z<.  Did you mean to set remote_side on the many-to-one side ?)r  get_propertyr   r   r   rI  r  r   r  _setup_entitycommon_parentr  r   _configure_startedr   r)   r(   )r   r  r?  s      r   _add_reverse_propertyz*RelationshipProperty._add_reverse_property)  s:   (((G%!56,, !%)  	  u- 	  -""5)##D)||))$++6&& eT[[2  $$9i"88%//1&& $0  2 9 %r   c                N    | j                   j                          | j                  S )zReturn the target mapped entity, which is an inspect() of the
        class or aliased class that is referenced by this
        :class:`.RelationshipProperty`.

        )r  r  r  r   s    r   r  zRelationshipProperty.entityU  s     	$$&{{r   c                .    | j                   j                  S )zcReturn the targeted :class:`_orm.Mapper` for this
        :class:`.RelationshipProperty`.

        r  r   s    r   r  zRelationshipProperty.mapper_  s     {{!!!r   c                   | j                          | j                          | j                          | j                          | j	                          | j                  | j                         | j                          | j                          | j                  j                          t        | 1          t        d| j                  d            | _        y )Nr_   ))r   ru   )_check_conflicts_process_dependent_argumentsr  _setup_registry_dependencies_setup_join_conditions_check_cascade_settingsr  
_post_init_generate_backrefr   "_warn_for_conflicting_sync_targetsr   do_initr   _get_strategyr   )r   r   s    r   r  zRelationshipProperty.do_initg  s    ))+))+##%$$T]]3 ??A"$,,-BC
r   c                    | j                   j                  j                  j                  | j                  j                  j                         y r   )r  r  registry_set_depends_onr  r   s    r   r  z1RelationshipProperty._setup_registry_dependenciesv  s3    ##33KK''	
r   c                   | j                   }dD ],  }t        ||      }|j                  | j                  d          . dD ]Q  }t        ||      }|j                  }|t        t        j                  t        j                  ||            |_        S |j                  j                  }|'t        |      rt        j                  d|d| d      |j                  j                  d	urU|j                  j                  ?t        d
 t!        j"                  |j                  j                        D              | _        nd	| _        t!        j$                  d t!        j&                  |j(                  j                        D              | _        t!        j$                  d t!        j&                  |j,                  j                        D              | _        y)zConvert incoming configuration arguments to their
        proper form.

        Callables are resolved, ORM annotations removed.

        )r   r   r   r   r   r   r   )r   r   Nargnamezsecondary argument z passed to to relationship() z must be a Table object or other FROM clause; can't send a mapped class directly as rows in 'secondary' are persisted independently of a class that is mapped to that same table.Fc              3  h   K   | ]*  }t        j                  t        j                  |d        , yw)r   r  Nr8   r   r;   r   r4  r  s     r   r6  zDRelationshipProperty._process_dependent_arguments.<locals>.<genexpr>  s7      "    ,,a "   02c              3  h   K   | ]*  }t        j                  t        j                  |d        , yw)r   r  Nr  r  s     r   r6  zDRelationshipProperty._process_dependent_arguments.<locals>.<genexpr>  s7      :
  ((!^ :
r   c              3  h   K   | ]*  }t        j                  t        j                  |d        , yw)r   r  Nr  r  s     r   r6  zDRelationshipProperty._process_dependent_arguments.<locals>.<genexpr>  s7      +
  ((!] +
r   )r   rO  r   _clsregistry_resolversr   r.   r8   r   r;   r   r   r   r   r   r   r7  r6   to_list
column_setto_column_setr   r   r   )r   	init_argsattrrel_argvalr   s         r   r  z1RelationshipProperty._process_dependent_arguments{  s    OO	
 
	ND i.G--d.I.I!.LM
	N 3 	Di.G""C#2$$00#t$ 		 ''00	 %5i%@&&
 *3D	:  ''u4""++7! " i&8&8&A&AB	" DM "DM*.// :
 ''	(>(>(G(GH	:
 +
'  ?? +
 ''	(=(=(F(FG	+
 
r   c
                0   |}
| | j                   | j                  ||       ny |}
|J |\t        |t              }t        |t              }|rd| _        d| j
                  ff| _        n"|r d| _        d| j
                  ff| _        ndx}}t        |
      }
t        |
d      r|
j                  }t        |t              r\t        |t        j                        rB| j                  At        j                   |      rt#        j$                  d| d      || _        n|s	|sd| _        |
j(                  rqt        |t              r*t        |t*        j,                        r|
j(                  d   }n|
j(                  d	   }t        |d
      r|j.                  }t1        ||      }
n@|}
n=t#        j$                  d|
 d      t        |
d
      r|
j.                  }
t1        |
|      }
| j                  |s	|sd| _        | j                   t3        d|
      | _         y y )Nr}   r   r~   F
__origin__zCollection annotation type z cannot be instantiated; please provide an explicit 'collection_class' parameter (e.g. list, set, etc.) to the relationship() function to accompany this annotationr   __forward_arg__zGeneric alias z requires an argumentz_RelationshipArgumentType[_T])r   _raise_for_required
issubclassr$   r    r   r   rL   hasattrr,  r   rv  r   r   r   _py_inspect
isabstractr   r   r   __args__typingMappingr.  rN   r   )r   	decl_scanr  clsoriginating_moduler  mapped_container
annotationextracted_mapped_annotationis_dataclass_fieldr   is_write_only
is_dynamic
arg_origintype_argstr_arguments                   r   declarative_scanz%RelationshipProperty.declarative_scan  s(    /&.}}$((c2.!---'&'7IM#$4mDJ(	&,dii%8$:!%	&,dii%8$:!)..MJ-h78\*!,,J*d+
CNN1 ((0"--j9$229* F) )  -7D)":$  j$/J5  (004H'003H8%67#+#;#;L>$&8 H  (H**$XJ.CD  X01//H6,H
 !!)! DL ==  !@(KDM !r   zsqlalchemy.orm.mapperc                   d| j                   v ry t        j                  j                  }|r|}n| j                  }t        |t              r!t        d | j                  |                   }n1t        |      r$t        |t        |j                  f      s |       }n|}t        |t              rt        |d      }nG	 t        |      }t!        |d      s/t        j"                  d| j$                  dt        |      d      || _        | j&                  j(                  | _        y # t        j                  $ r d }Y uw xY w)	Nr  z_ExternalEntityType[Any]F	configurer  relationship 'z2' expects a class or a mapper argument (received: ))__dict__r6   	preloaded
orm_mapperr   r   r   r   _clsregistry_resolve_namer   rv  r[   r   r7   r   r  r1  r   r  r  persist_selectabletarget)r   _RelationshipProperty__argument	mapperlibr   resolved_argumentr  s         r   r  z"RelationshipProperty._setup_entity+  s&   t}}$NN--	!H}}H h$ !%*8..x8:! h
tY--.)
 !)
 ( '.!"3uEF !23 68,** xx&7!8:  kk44 // s   <D% %D=<D=c                   t        di d| j                  j                  d| j                  j                  d| j                  j                  d| j                  j                  d| j
                  j                  j                  d| j
                  j                  j                  d| j
                  j                  j                  d| j                  j                  d	| j                  j                  d
| j                  d| j                  d| j                  d| j                  d| d| j                    d| j"                  x| _        }|j                  | _        |j                  | _	        |j                  | _        |j&                  | _        |j                  | _        |j(                  | _        |j*                  | _        |j,                  | _        |j.                  | _        |j2                  | _        y )Nparent_persist_selectablechild_persist_selectableparent_local_selectablechild_local_selectabler   r   r   parent_equivalentschild_equivalentsconsider_as_foreign_keysr   r   self_referentialr  support_synccan_be_synced_fnr   )r   r  rM  r  local_tabler   r   r   r   r   _equivalent_columnsr  r   r   r   rQ  r   _columns_are_mappedr   r   remote_columnsr   r   foreign_key_columnsr   r   )r   jcs     r   r  z+RelationshipProperty._setup_join_conditions[  s   $1 %
&*kk&D&D%
%)[[%C%C%
 %)KK$;$;%
 $(;;#:#:	%

 33<<%
 oo//88%
 //77@@%
  ${{>>%
 #kk==%
 &*%D%D%
  $66%
 ((%
 "66%
 %
 "]]*%
  "55!%
 	
r$ >>--"$"7"7,,--!#!5!5(*(>(>%+-+I+I(r   c                     | j                   d   S )Nr   r#  r   s    r   _clsregistry_resolve_argz-RelationshipProperty._clsregistry_resolve_argy       **1--r   c                     | j                   d   S )Nr   rd  r   s    r   rL  z.RelationshipProperty._clsregistry_resolve_name  rf  r   zsqlalchemy.orm.clsregistryc                    t         j                  j                  j                  } || j                  j
                  |       S r   )r6   rJ  orm_clsregistry	_resolverr  r  )r   rj  s     r   r#  z+RelationshipProperty._clsregistry_resolvers  s0     NN22<<	++T22r   c           	     p   | j                   j                  rt        | j                   j                  d      j	                  | j
                        set        j                  d| j
                  d| j                   j                  j                  d| j                   j                  j                  d      yy)zOTest that this relationship is legal, warn about
        inheritance conflicts.FrE  z)Attempting to assign a new relationship 'z$' to a non-primary mapper on class 'zm'.  New relationships can only be added to the primary mapper, i.e. the very first mapper created for class 'z' N)	r  non_primaryr   r  has_propertyr  r   r   r   r   s    r   r  z%RelationshipProperty._check_conflicts  s     ;;""<KK%,

,txx
 ,! && HHKK&&//KK&&//	 ,!"r   c                    | j                   S )z\Return the current cascade setting for this
        :class:`.RelationshipProperty`.
        )r  r   s    r   r   zRelationshipProperty.cascade  s    
 }}r   c                &    | j                  |       y r   )_set_cascader   r   s     r   r   zRelationshipProperty.cascade  s    '"r   c                
   t        |      }| j                  r(t        |j                  t         j                              }d| j                  v r| j                  |       || _        | j                  r|| j                  _        y y )Nr  )	r/   r   intersection_viewonly_cascadesrI  r  r  r   r   )r   cascade_argr   s      r   rp  z!RelationshipProperty._set_cascade  sp     -==$$$^%F%FGG t}}$((1%%18D&&. &r   c                x   |j                   r| j                  s| j                  t        u s| j                  t        u rot        j                  d| | j                  t        u rdnd| j                  j                  j                  | j                  j                  j                  dz  d      | j                  dk(  r d|v sd	|v rt        j                  d
| z        |j                   rT| j                  j                         j                  j                  | j                  | j                  j                  f       y y )Na  For %(direction)s relationship %(rel)s, delete-orphan cascade is normally configured only on the "one" side of a one-to-many relationship, and not on the "many" side of a many-to-one or many-to-many relationship.  To force this relationship to allow a particular "%(relatedcls)s" object to be referenced by only a single "%(clsname)s" object at a time via the %(rel)s relationship, which would allow delete-orphan cascade to take place in this direction, set the single_parent=True flag.zmany-to-onezmany-to-many)relr   clsname
relatedclsbbf0codeallr  r  z^On %s, can't set passive_deletes='all' in conjunction with 'delete' or 'delete-orphan' cascade)delete_orphanr   r   r'   r(   r   r   r  r  r   r  r   primary_mapper_delete_orphansr  r  rq  s     r   r  z,RelationshipProperty._check_cascade_settings  s   !!&&:-91L&&/    >>Y6 &+#{{11::"&++"4"4"="=	. 1 6 5(?g#=&&;=AB 
   KK&&(88??4;;--. !r   c                l    | j                   |j                  v xr |j                  | j                      | u S )zaReturn True if this property will persist values on behalf
        of the given mapper.

        )r  relationshipsr  s     r   _persists_forz"RelationshipProperty._persists_for  s7     HH,,, 7$$TXX.$6	
r   c                <   | j                   j                  j                  }|D ]w  }||j                  j	                  |      r!| j
                  j                  j                  j	                  |      rQ| j                  j                  j	                  |      rw y y)zReturn True if all columns in the given collection are
        mapped by the tables referenced by this :class:`.RelationshipProperty`.

        FT)r   r   r   r  contains_columnr  rM  rN  )r   colsr   r  s       r   r_  z(RelationshipProperty._columns_are_mapped  s     OO--66	 	A$)D)DQ)G;;1133CCkkmm33A6	 r   c           
     |   | j                   j                  ry| j                  p| j                  sct	        | j                  t
              r| j                  i }}n| j                  \  }}| j                  j                         }|j                  svt        |j                               j                  |j                        }|D ]?  }|j                  |      s|j                  r"t        j                  d|d| d|d       | j                   M|j#                  d| j$                  j&                        }|j#                  d| j$                  j(                        }nO|j#                  d| j$                  j*                        }|j#                  dd      }|rt        j,                  d      |j#                  d	| j.                        }| j                   j                         }	|j1                  d
| j2                         |j1                  d| j4                         |j1                  d| j6                         |j1                  d| j8                         || _        t;        |	| j                   f|||| j<                  d|}
|j?                  ||
d       | j                  r| jA                  | j                         yy)zlInterpret the 'backref' instruction to create a
        :func:`_orm.relationship` complementary to this one.NzError creating backref 'z' on relationship 'z+': property of that name exists on mapper 'r  r   r   zOCan't assign 'secondaryjoin' on a backref against a non-secondary relationship.r   r   r   r   r   )r   r   r   r   T)warn_for_existing)!r  rl  r   r   r   r   r  r  concreter   iterate_to_rootunionself_and_descendantsrm  r   r   r   popr   secondaryjoin_minus_localprimaryjoin_minus_localprimaryjoin_reverse_remoterI  r   
setdefaultr   r   r   r   r   r  _configure_propertyr	  )r   backref_keyr]  r  checkmr)  r*  r   r  relationships              r   r  z&RelationshipProperty._generate_backref  sv    ;;""<<#D,?,?$,,,&*llBV&*ll#V[[//1F??F2245;;//  A~~k21::$22  +D!5  ~~) ZZ!((BB ZZ#((@@
 ZZ!((CC ZZ6 44@ 
 ":: ? ?L [[//1Fj$--8mT-=-=>/1E1EFnd.?.?@"-D/  )#xx L &&\T '  &&t':':; r   zsqlalchemy.orm.dependencyc                    t         j                  j                  }| j                  | j                  t
        u| _        | j                  s!|j                  j                  |       | _	        y y r   )
r6   rJ  orm_dependencyr   r   r(   r   rZ   from_relationshipr   )r   
dependencys     r   r  zRelationshipProperty._post_initW  sV    ^^22
<<>>:DL}}..@@0 & r   c                2    | j                   }|j                  S )zPmemoize the 'use_get' attribute of this RelationshipLoader's
        lazyloader.)r   use_get)r   strategys     r   r  zRelationshipProperty._use_getb  s    
 &&r   c                L    | j                   j                  | j                        S r   )r  r  r  r   s    r   rQ  z)RelationshipProperty._is_self_referentialj  s    {{((55r   c                   d}|r| j                   d}|.|r,| j                  j                  r| j                  j                  }|r|j                  }||j
                  }d}n| j                  }|O| j                  j
                  }| j                  j                  rd}| j                  rE|C|j                         }d}n0|| j                  j                  us| j                  j                  rd}|j                  }	|xs, |d uxr& || j                  j                  uxs |j                  }| j                  j                  ||||	|      \  }
}}}}|| j                  j                  }|| j                  j                  }|
|||||fS )NFT)r   r  with_polymorphicr   r  r  r  rQ  rR  rS  _is_subqueryr   join_targetsr]  )r   r$  r#  rL  r%  r&  r  aliaseddest_mapperra  r   r   r   r-  s                 r   r'  z"RelationshipProperty._create_joinsn  s     t~~9G$!dkk&B&B$(KK$L$L!(//K&"0";";++K""kk44O{{++((->-F"1"G"G"I4;;#K#KK{{++G!99 
T) !{{??@ 2$11 	   --
	
 $ $ 7 7""kk55O
 	
r   )NN)Hr   z'Optional[_RelationshipArgumentType[_T]]r   z(Optional[_RelationshipSecondaryArgument]r   Optional[bool]r   zEOptional[Union[Type[Collection[Any]], Callable[[], Collection[Any]]]]r   ,Optional[_RelationshipJoinConditionArgument]r   r  r   Optional[str]r   _ORMOrderByArgumentr   zOptional[ORMBackrefArgument]r   r  r   r   r   r   r   r   r   zOptional[_AttributeOptions]r   _LazyLoadArgumentTyper   zUnion[Literal['all'], bool]r   r   r   r   r   r   r   #Optional[_ORMColCollectionArgument]r   r  r   zOptional[int]r   z4Optional[Type[RelationshipProperty.Comparator[Any]]]r   r   r   r   r   r  r   r   r   zOptional[Type[Query[Any]]]r   zOptional[_InfoType]r   zLiteral[None, False]r   r  r   r  r   zLiteral[True]r   zLiteral[False]r   r   r   r   )r   r   r   r   )r  Mapper[Any]r   r   )TN)r  objectr&  r   r  zOptional[_EntityType[Any]]r   r   )FNT)
ry  r   r  r   rC  Optional[_CoreAdapterProto]r&  r   r   r   )
r  r  ry  r  r{  rR   r  r   r   zCallable[[], Any])FN)r  r   rC  r  r   r   r   r   )r  r]   r  r  r  rR   r  r  r  rR   r  r   r  zDict[Any, object]r  z#Dict[_IdentityKeyType[Any], object]r   r   )
ry  zInstanceState[_O]r{  rR   r  r   r  r"   r   z&Sequence[Tuple[InstanceState[_O], _O]]r   )rq  r   ry  r  r{  rR   r  zSet[InstanceState[Any]]r  z.Optional[Callable[[InstanceState[Any]], bool]]r   zDIterator[Tuple[Any, Mapper[Any], InstanceState[Any], _InstanceDict]]r   )r   RelationshipProperty[Any]r  r  r   r   )r  r   r   r   )r   z_InternalEntityType[_T])r   rt   r   r   )r7  rY   r  rU   r8  z	Type[Any]r9  r  r  r   r:  zOptional[Type[Mapped[Any]]]r;  Optional[_AnnotationScanType]r<  r  r=  r   r   r   )rO  r   r   r   )r   r   )r   z>Callable[[str], Callable[[], Union[Type[Any], Table, _ModNS]]])r   zmTuple[Callable[[str], Callable[[], Union[Type[Any], Table, _ModNS]]], Callable[[str, bool], _class_resolver]])r   r/   )r   Union[str, CascadeOptions]r   r   )ru  r  r   r   )r   r/   r   r   )r  r  r   r   )r  r   r   r   )FNNNFr   )r$  r   r#  r   rL  r   r%  z"Optional[_InternalEntityType[Any]]r&  r   r  r  r   zTuple[ColumnElement[bool], Optional[ColumnElement[bool]], FromClause, FromClause, Optional[FromClause], Optional[ClauseAdapter]])?r   r   r   r   r   _RELATIONSHIP_TOKENstrategy_wildcard_keyinherit_cache_links_to_entity_is_relationshipr   rt  r   r   r   r   r  r6   MemoizedSlotsr*   rr   r   r  rG  rw  r  r  r  r"   r  r  r  r	  r  staticmethodr  r	  memoized_propertyr  r  r  r  r  rC  preload_moduler  r  re  rL  r#  r  r   setterrp  r  r  r_  r  r  r  rQ  r'  __classcell__)r   s   @r   r   r   5  s   	 -@@M <@8?$$00##""%% 7755((**##!77..$$!! =A>BH#
 #' DHFJ(,(-04"&!+9=&.7< $$"&<@;?$( #.2 %26$(*.'+!&*+06:/4UH#9H# <H#
  H#
H# BH# DH# &H# &H# .H#  H# H#  !H#" #H#$ 7%H#& $'H#( 5)H#* +H#, -H#.  /H#0 :1H#2 93H#4 "5H#6
7H#< =H#> ?H#@ ,AH#B CH#D 0EH#F "GH#H (IH#J %KH#L MH#N $OH#P )QH#R 4SH#T )-UH#T$
j	T'')< j	^ !%26	

 
 0	

 

. !&48 $BB B 2	B
 B 
BHii "i 	i
 #i 
iZ #(48 2 
	,A__ )_ #	_
 '_ !_ _ &_  C_ 
_L  +667 7 7 	7
 7 
07> CG;D;D ";D 	;D
 0;D @;D 
N;Dz 2 2 '('1J'	' '*X 
  
" "


J
XbL)bL  bL 	bL
 *bL bL 6bL 2bL &CbL !bL 
bLH T01-5 2-5^J< .	/. .
 .	G. .
 
T563
3 7 3&   ^^# #9,\	
 N<` T45 6 
    
6 6
 $)2604=A %:<Q
 Q
 0Q
 .	Q

 ;Q
 Q
 8Q

Q
r   r   c                0    dfd|  |       } d | S )Nc                    t        | t        j                        r | j                   j                               } | j                         | S )N)clone)r   r9   r@   rU  copy_copy_internals)elemr   r  s    r   r  z _annotate_columns.<locals>.clone  sC    dJ334>>"2+"2"2"45D5)r   )r  r   r   r   r   )elementr   r  s    `@r   r   r     s#     .ENr   c                  ~   e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
ed<   d
ed<   ded<   ded<   ded<   ded<   ded<   ded<   ddddddddddd d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dCdZdDdZdDdZdDdZedEd       Z	edEd        Z
ej                  dEd!       ZdFd"Zej                  dGd#       Zej                  dGd$       ZdDd%ZdDd&ZdDd'ZdGd(ZdGd)ZdDd*ZdDd+Z	 	 	 	 	 	 dHd,ZdDd-ZdDd.ZdDd/ZdDd0ZdDd1ZdDd2ZdDd3Z	 	 	 	 	 	 dId4Z dDd5Z!	 	 	 	 dJd6Z"dDd7Z# e$jJ                         Z&d8ed9<   dDd:Z'ej                  dKd;       Z(ej                  dKd<       Z)ej                  dKd=       Z*	 	 	 	 dLd>Z+	 	 	 	 	 	 dMd?Z,ej                  dNd@       Z-	 	 dO	 	 	 	 	 	 	 	 	 	 	 dPdAZ.dQdRdBZ/y)Sr   r   primaryjoin_initialr   r   r   r   r   r  r  r   r   r   r+   r   rk   rS  rT  rU  rV  r   r   NFTc                      yNTr   )r  s    r   <lambda>zJoinCondition.<lambda>  s    r   )r   r   r   rW  rX  rY  r   r   rZ  r[  r\  c                  || _         || _        || _        || _        || _        |	| _        || _        || _        || _        |
| _	        || _
        || _        || _        || _        || _        || _        | j!                          | j"                  J | j%                          | j'                          | j)                          | j+                          | j-                          | j/                          | j1                  | j"                  d       | j                  | j1                  | j                  d       | j3                          | j5                          | j7                          y NTF)rS  rU  rT  rV  rW  rX  r  r   r   rY  r   _remote_sider  rZ  r[  r\  _determine_joinsr   _sanitize_joins_annotate_fks_annotate_remote_annotate_local_annotate_parentmapper_setup_pairs_check_foreign_cols_determine_direction_check_remote_side
_log_joins)r   rS  rT  rU  rV  r   r   r   rW  rX  rY  r   r   rZ  r  r[  r\  s                    r   r   zJoinCondition.__init__  sC   ( *C&'>$(@%&<#"4!2#. *"(@%#5 '	 0( 0+++##%  !1!148)$$T%7%7?!!#!r   c           	        | j                   j                  } |j                  d| j                   | j                          |j                  d| j                   | j                          |j                  d| j                   dj                  d | j                  D                      |j                  d| j                   dj                  d | j                  xs g D                      |j                  d| j                   dj                  d	 | j                  D                      |j                  d
| j                   dj                  d | j                  D                      |j                  d| j                   dj                  d | j                  D                      |j                  d| j                   | j                         y )Nz%s setup primary join %sz%s setup secondary join %sz%s synchronize pairs [%s],c              3  4   K   | ]  \  }}d |d|d  yw(z => rH  Nr   r4  lr  s      r   r6  z+JoinCondition._log_joins.<locals>.<genexpr>	  s      *01a1%   z#%s secondary synchronize pairs [%s]c              3  4   K   | ]  \  }}d |d|d  ywr  r   r  s      r   r6  z+JoinCondition._log_joins.<locals>.<genexpr>$	  s!      Q !"1%r  z%s local/remote pairs [%s]c              3  4   K   | ]  \  }}d |d|d  yw)r  z / rH  Nr   r  s      r   r6  z+JoinCondition._log_joins.<locals>.<genexpr>,	  s      )/!Qq!$r  z%s remote columns [%s]c              3  &   K   | ]	  }d |z    ywz%sNr   r4  r~  s     r   r6  z+JoinCondition._log_joins.<locals>.<genexpr>3	  s     ?CTCZ?   z%s local columns [%s]c              3  &   K   | ]	  }d |z    ywr  r   r  s     r   r6  z+JoinCondition._log_joins.<locals>.<genexpr>8	  s     >CTCZ>r  z%s relationship direction %s)r  loggerr   r   r   joinr   r   r   r`  r   r   )r   r3   s     r   r  zJoinCondition._log_joins	  sz   ii+TYY8H8HI-tyy$:L:LM'IIHH 484J4J 	
 	1IIHH ">>D" 	
 	(IIHH 373J3J 	
 	$IIHH?4+>+>??	

 	#IIHH>4+=+=>>	

 	/DNNKr   c                    t        | j                  d      | _        | j                  t        | j                  d      | _        yy)a_  remove the parententity annotation from our join conditions which
        can leak in here based on some declarative patterns and maybe others.

        "parentmapper" is relied upon both by the ORM evaluator as well as
        the use case in _join_fixture_inh_selfref_w_entity
        that relies upon it being present, see :ticket:`3364`.

        )r   	proxy_keyvaluesN)rD   r   r   r   s    r   r  zJoinCondition._sanitize_joins<	  sI     ,%B
 )!1""+H"D *r   c                R   | j                   .| j                  "t        j                  d| j                  z        	 | j
                  xs d}| j                  | j                   2t        | j                  | j                  | j                  |      | _         | j                  3t        | j                  | j                  | j                  |      | _        y| j                  | _        y| j                  3t        | j                  | j                  | j                  |      | _        y| j                  | _        y# t        j                  $ re}| j                  1t        j                  d| j                  d| j                  d      |t        j                  d| j                  z        |d}~wt        j                  $ re}| j                  1t        j                  d| j                  d| j                  d	      |t        j                  d
| j                  z        |d}~ww xY w)zDetermine the 'primaryjoin' and 'secondaryjoin' attributes,
        if not passed to the constructor already.

        This is based on analysis of the foreign key relationships
        between the parent and target mapped selectables.

        NzMProperty %s specified with secondary join condition but no secondary argument)a_subsetrY  zOCould not determine join condition between parent/child tables on relationship zG - there are no foreign keys linking these tables via secondary table 'z'.  Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify 'primaryjoin' and 'secondaryjoin' expressions.a  Could not determine join condition between parent/child tables on relationship %s - there are no foreign keys linking these tables.  Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.zP - there are multiple foreign key paths linking the tables via secondary table 'z'.  Specify the 'foreign_keys' argument, providing a list of those columns which should be counted as containing a foreign key reference from the secondary table to each of the parent and child tables.a'  Could not determine join condition between parent/child tables on relationship %s - there are multiple foreign key paths linking the tables.  Specify the 'foreign_keys' argument, providing a list of those columns which should be counted as containing a foreign key reference to the parent table.)r   r   r   r   r  rY  rH   rT  rV  r  rS  rU  r   NoForeignKeysErrorAmbiguousForeignKeysError)r   rY  nfeafes       r   r  zJoinCondition._determine_joinsN	  s    )dnn.D&&(*.))4 I	'+'D'D'L$~~)%%-)755!%!<!<1I	*D& ++3'566!%!=!=1I	(D$ (,'?'?D$++3'56655!%!=!=1I	(D$ (,'?'?D$(( 	~~)// '+iiA	 	 //: =AIIF  // 	~~)66 37))T^^M
 
 66A DH99M 	s8   BD8 D8 '>D8 &D8 8H&A F++H&A H!!H&c                0    t        | j                  d      S Nlocalr   r  )rD   r   r   s    r   r  z%JoinCondition.primaryjoin_minus_local	  s     0 09LMMr   c                L    | j                   J t        | j                   d      S r  )r   rD   r   s    r   r  z'JoinCondition.secondaryjoin_minus_local	  s(    !!--- 2 2;NOOr   c                    | j                   r%dd}t        j                  | j                  i |      S | j                  rt        | j                  d      S t        | j                        S )a(  Return the primaryjoin condition suitable for the
        "reverse" direction.

        If the primaryjoin was delivered here with pre-existing
        "remote" annotations, the local/remote annotations
        are reversed.  Otherwise, the local/remote annotations
        are removed.

        c                    d| j                   v r.t        | j                         }|d= d|d<   | j                  |      S d| j                   v r.t        | j                         }|d= d|d<   | j                  |      S y )Nr   Tr  )_annotationsrt  _with_annotations)r  r   r   s      r   replacez9JoinCondition.primaryjoin_reverse_remote.<locals>.replace	  s    w333W112A(!%AgJ"44Q77 4 44W112A'
"&AhK"44Q77r   r  r  r  r   r   r   r   zOptional[_CE])_has_remote_annotationsr<   replacement_traverser   _has_foreign_annotationsrD   )r   r  s     r   r  z(JoinCondition.primaryjoin_reverse_remote	  sd     '' 001A1A2wOO,,'$$-@  ((8(899r   c                Z    t        j                  |i       D ]  }||j                  v s y yr  )r<   iterater  )r   r5  r;  r~  s       r   _has_annotationzJoinCondition._has_annotation	  s4    ##FB/ 	CS---	 r   c                :    | j                  | j                  d      S Nr   r  r   r   s    r   r   z&JoinCondition._has_foreign_annotations	  s    ##D$4$4i@@r   c                :    | j                  | j                  d      S Nr   r  r   s    r   r  z%JoinCondition._has_remote_annotations	  s    ##D$4$4h??r   c                x    | j                   ry| j                  r| j                          y| j                          y)zAnnotate the primaryjoin and secondaryjoin
        structures with 'foreign' annotations marking columns
        considered as foreign.

        N)r   rY  _annotate_from_fk_list_annotate_present_fksr   s    r   r  zJoinCondition._annotate_fks	  s1     (((('')&&(r   c                     d fd}t        j                   j                  i |       _         j                  't        j                   j                  i |       _        y y )Nc                H    | j                   v r| j                  ddi      S y Nr   T)rY  rU  r  r   r   s     r   check_fkz6JoinCondition._annotate_from_fk_list.<locals>.check_fk	  s*    $777(()T):;;r   r  )r<   r  r   r   )r   r  s   ` r   r
  z$JoinCondition._annotate_from_fk_list	  s]    	
 $88b(
 )!)!>!>""B"D *r   c                f   | j                   *t        j                  | j                   j                        n
t	               	 	 	 	 	 	 dfddfd}t        j                  | j                  i d|i      | _        | j                  )t        j                  | j                  i d|i      | _        y y )Nc                    t        | t        j                        r@t        |t        j                        r&| j                  |      r| S |j                  |       r|S r| v r|vr| S |v r| vr|S y r   )r   r4   Column
references)absecondarycolss     r   
is_foreignz7JoinCondition._annotate_present_fks.<locals>.is_foreign
  sn     !V]]+
1fmm0L<<?H\\!_H%!=*@H-'A],BHr   binaryc                4   t        | j                  t        j                        r$t        | j                  t        j                        sy d| j                  j
                  vrd| j                  j
                  vr | j                  | j                        }|}|j                  | j                        r#| j                  j                  ddi      | _        y |j                  | j                        r#| j                  j                  ddi      | _        y y y y y r  )r   leftr5   rA   rightr  comparerU  )r  r~  r  s     r   visit_binaryz9JoinCondition._annotate_present_fks.<locals>.visit_binary
  s    S..c.?.?@ !9!99V\\%>%>> fll;?{{6;;/&,kk&;&;Y<M&NV\\2'-||'='=&-( 3 # ? :r   )r  r   r  r   r   zOptional[ColumnElement[Any]]r  BinaryExpression[Any]r   r   )	r   r6   r%  r  r   r<   r  r   r   )r   r  r  r  s     @@r   r  z#JoinCondition._annotate_present_fks
  s    >>% OODNN,<,<=MEM	!	&8	)	"	& $33b8\":
 )!)!9!9""B<(@"D *r   c                    | j                   | j                  ddfd}t        j                  | j                  i d|i       S )zvReturn True if the join condition contains column
        comparisons where both columns are in both tables.

        Fr  c                   | j                   | j                  }}t        |t        j                        rt        |t        j                        rsj                  |j                        rWj                  |j                        r;j                  |j                        rj                  |j                        rdy y y y y y y r  )r  r  r   r9   r@   is_derived_fromtable)r  r  fmtptresults      r   r  z;JoinCondition._refers_to_parent_table.<locals>.visit_binaryA
  s    ;;qA1j556q*"9"9:&&qww/&&qww/&&qww/&&qww/ 0 0 0 0 ; 7r   r  )rS  rT  r<   rT  r   )r   r  r&  r'  r(  s     @@@r   _refers_to_parent_tablez%JoinCondition._refers_to_parent_table8
  sI    
 ++**	 	$**B<0HIr   c                B    t        | j                  | j                        S )z5Return True if parent/child tables have some overlap.)rI   rS  rT  r   s    r   _tables_overlapzJoinCondition._tables_overlapQ
  s"     #**D,I,I
 	
r   c                T   | j                   ry| j                  | j                          y| j                  s| j                  r| j                          y| j                         r| j                  d d       y| j                         r| j                          y| j                          y)zAnnotate the primaryjoin and secondaryjoin
        structures with 'remote' annotations marking columns
        considered as part of the 'remote' side.

        Nc                    d| j                   v S r  )r  )r~  s    r   r  z0JoinCondition._annotate_remote.<locals>.<lambda>g
  s    I)9)99 r   F)r  r   _annotate_remote_secondaryr   r  _annotate_remote_from_argsr)  _annotate_selfrefr+  _annotate_remote_with_overlap%_annotate_remote_distinct_selectablesr   s    r   r  zJoinCondition._annotate_remoteX
  s     ''>>%++-%%):):++-))+""95 !!#..0668r   c                    | j                   J | j                   dfd}t        j                  | j                  i |      | _        | j                  J t        j                  | j                  i |      | _        y)z^annotate 'remote' in primaryjoin, secondaryjoin
        when 'secondary' is present.

        Nc                b    j                   j                  |       r| j                  ddi      S y Nr   T)r  r  rU  )r  r   fixed_secondarys     r   replz6JoinCondition._annotate_remote_secondary.<locals>.replw
  s0      009(((D)9::r   r  )r   r<   r  r   r   )r   r7  r6  s     @r   r.  z(JoinCondition._annotate_remote_secondaryn
  sy     ~~)))..	
 $88b$
 !!---%::D
r   c                j     d fd}t        j                   j                  i d|i       _        y)zxannotate 'remote' in primaryjoin, secondaryjoin
        when the relationship is detected as self-referential.

        r  c                   | j                   j                  | j                        }t        | j                   t        j
                        rt        | j                  t        j
                        rm | j                         r"| j                   j                  ddi      | _          | j                        r&|s#| j                  j                  ddi      | _        y y y sj                          y y r5  )r  r  r  r   r9   r@   rU  _warn_non_column_elements)r  equatedfnremote_side_givenr   s     r   r  z5JoinCondition._annotate_selfref.<locals>.visit_binary
  s    kk))&,,7G&++z'>'>?Jj55E fkk?"(++"7"748H"IFKfll#G#)<<#9#98T:J#KFL -4#&..0 'r   Nr  )r<   r  r   )r   r<  r=  r  s   ``` r   r0  zJoinCondition._annotate_selfref
  s/    	1 $33b8\":
r   c                h   | j                   rA| j                  rt        j                  d      | j                   D cg c]  \  }}|	 c}}n| j                  | j	                         r| j                  fdd       ydfd}t        j                  | j                  i |      | _        yc c}}w )zannotate 'remote' in primaryjoin, secondaryjoin
        when the 'remote_side' or '_local_remote_pairs'
        arguments are used.

        zTremote_side argument is redundant against more detailed _local_remote_side argument.c                    | v S r   r   )r~  r   s    r   r  z:JoinCondition._annotate_remote_from_args.<locals>.<lambda>
  s    sk/A r   Tc                F    | t              v r| j                  ddi      S y r5  )r   rU  )r  r   r   s     r   r7  z6JoinCondition._annotate_remote_from_args.<locals>.repl
  s+     c+..",,h-=>>r   Nr  )	r   r  r   r   r)  r0  r<   r  r   )r   r  r  r7  r   s       @r   r/  z(JoinCondition._annotate_remote_from_args
  s     ##  **   ,0+C+CD!Q1DK++K'')""#A4H  (<<  "d D Es   B.c                     dfd} j                   duxr,  j                   j                   j                   j                  u	 	 	 	 	 	 d fdt        j                   j
                  i d|i       _        y)zannotate 'remote' in primaryjoin, secondaryjoin
        when the parent/child tables have some set of
        tables in common, though is not a fully self-referential
        relationship.

        r  c                     | j                   | j                        \  | _         | _         | j                  | j                         \  | _        | _         y r   )r  r  )r  proc_left_rights    r   r  zAJoinCondition._annotate_remote_with_overlap.<locals>.visit_binary
  sE    (7V\\)%FK )8fkk)%FL&+r   Nc                ~   t        | t        j                        r{t        |t        j                        raj                  j                  j                  |      r8j                  j                  j                  |       r|j                  ddi      }| |fS rH|j                  j                  d      j                  j                  u r|j                  ddi      }| |fS rH| j                  j                  d      j                  j                  u r| j                  ddi      } | |fS j                          | |fS )Nr   Tr  )r   r9   r@   rT  r  r  rS  rU  r  r  r  r  r:  )r  r  check_entitiesr   s     r   rC  zDJoinCondition._annotate_remote_with_overlap.<locals>.proc_left_right
  s%    $
 7 78Zz..> 0022BB4466FFtL!OOXt,<=E ; &&**>:dii>N>NN4(89 ; %%)).9TYY=M=MM~~x&67 ; ..0;r   r  )r  r   r  r   r   z-Tuple[ColumnElement[Any], ColumnElement[Any]])r  r  r  r<   r  r   )r   r  rE  rC  s   ` @@r   r1  z+JoinCondition._annotate_remote_with_overlap
  s}    	 IIT!Ndii&6&6dii>N>N&N 		$	-?	:	2 $33b8\":
r   c                ^     d fd}t        j                   j                  i |       _        y)z}annotate 'remote' in primaryjoin, secondaryjoin
        when the parent/child tables are entirely
        separate.

        c                
   j                   j                  j                  |       r]j                  j                  j                  |       r%j                  j                  j                  |       r| j                  ddi      S y r5  )rT  r  r  rU  rV  rU  r  s     r   r7  zAJoinCondition._annotate_remote_distinct_selectables.<locals>.repl
  sj    ,,..>>wG0022BB7K..00@@I(((D)9::r   Nr  r<   r  r   )r   r7  s   ` r   r2  z3JoinCondition._annotate_remote_distinct_selectables
  s*    	 $88b$
r   c                H    t        j                  d| j                  z         y )NzNon-simple column elements in primary join condition for property %s - consider using remote() annotations to mark the remote side.)r6   r   r  r   s    r   r:  z'JoinCondition._warn_non_column_elements  s     		<>BiiH	
r   c                t   | j                  | j                  d      ry| j                  r3t        j                  | j                  D cg c]  \  }}|	 c}}      n)t        j                  | j
                  j                        dfd}t        j                  | j                  i |      | _        yc c}}w )aC  Annotate the primaryjoin and secondaryjoin
        structures with 'local' annotations.

        This annotates all column elements found
        simultaneously in the parent table
        and the join condition that don't have a
        'remote' annotation set up from
        _annotate_remote() or user-defined.

        r  Nc                P    d| j                   vr| v r| j                  ddi      S y )Nr   r  T)r  rU  )r  r   
local_sides     r   locals_z.JoinCondition._annotate_local.<locals>.locals_  s0    w333:8M(('499r   r  )	r  r   r   r6   r%  rS  r  r<   r  )r   r  r  rM  rL  s       @r   r  zJoinCondition._annotate_local
  s      0 0':##!%!9!9:v1:J )G)G)I)IJJ	
 $88b'
 ;s   	B4
c                ^     d fd}t        j                   j                  i |       _        y )Nc                    d| j                   v r'| j                  dj                  j                  i      S d| j                   v r'| j                  dj                  j                  i      S y )Nr   r  r  )r  rU  r  r  r  r  s     r   parentmappers_z<JoinCondition._annotate_parentmapper.<locals>.parentmappers_)  sb    7///((.$)):J:J)KLLG000((.$)):J:J)KLLr   r  rH  )r   rP  s   ` r   r  z$JoinCondition._annotate_parentmapper(  s*    	 $88b.
r   c                ^   | j                   s#t        j                  d| j                  d      t	        j
                  | j                  j                        j                  | j                  j                        }| j                   D ]#  \  }}||v st	        j                  d|d       % y )Nr  a   could not determine any unambiguous local/remote column pairs based on join condition and remote_side arguments.  Consider using the remote() annotation to accurately mark those elements of the join condition that are on the remote side of the relationship.zExpression z is marked as 'remote', but these column(s) are local to the local side.  The remote() annotation is needed only for a self-referential relationship where both sides of the relationship refer to the same tables.)r   r   r   r  r6   r%  rS  r  
differencerT  r   )r   
not_target_rmts       r   r  z JoinCondition._check_remote_side4  s    &&&& (,yy3	 	 ..00j66889  11 	3*$II !	r   c                   d}| j                  |d      }t        |      }|rt        | j                        }nt        | j                        }| j                  r|s| j                  s|ry| j                  r<|r:|s8d|xr dxs dd|d| j
                  d	}|d
z  }t        j                  |      d|xr dxs dd|d| j
                  d	}|dz  }t        j                  |      )zHCheck the foreign key columns collected and emit error
        messages.Fr   NzbCould not locate any simple equality expressions involving locally mapped foreign key columns for primaryr   z join condition 'z' on relationship r  a    Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or are annotated in the join condition with the foreign() annotation. To allow comparison operators other than '==', the relationship can be marked as viewonly=True.z6Could not locate any relevant foreign key columns for z  Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or are annotated in the join condition with the foreign() annotation.)_gather_columns_with_annotationr   r   r   r[  r  r   r   )r   rH   rW  can_syncforeign_colshas_foreignerrs          r   r  z!JoinCondition._check_foreign_colsP  s    ;;I
 <(D223HD<<=H %%+
 X )	8[8"II  IC &&s++ )	8[8"II  C &&s++r   c                   | j                   t        | _        yt        j                  | j
                  j                        }t        j                  | j                  j                        }|j                  | j                        }|j                  | j                        }|r|r| j                  | j                  dd      }| j                  | j                  d      D ch c]  }d|j                  vr| }}|rI|rG| j                  j                  | j                        }|j                  |      }|j                  |      }|r|st         | _        y|r|st"        | _        yt%        j&                  d| j(                  z        |rt         | _        y|rt"        | _        yt%        j&                  d| j(                  z        c c}w )z[Determine if this relationship is one to many, many to one,
        many to many.

        Nr   r   aD  Can't determine relationship direction for relationship '%s' - foreign key columns within the join condition are present in both the parent and the child's mapped tables.  Ensure that only those columns referring to a parent column are marked as foreign, either via the foreign() annotation or via the foreign_keys argument.zCan't determine relationship direction for relationship '%s' - foreign key columns are present in neither the parent nor the child's mapped tables)r   r'   r   r6   r%  rS  r  rT  rs  ra  rX  r   r  r`  r   rR  r)   r(   r   r   r  )	r   
parentcols
targetcolsonetomany_fkmanytoone_fkonetomany_localr  manytoone_localself_equateds	            r   r  z"JoinCondition._determine_direction  s   
 )'DN)G)G)I)IJJ)F)F)H)HIJ &2243K3KLL &2243K3KLL #'"F"F$$h	# "AA(()#  q~~5	 # # ##'#6#6#C#C**$L '6&@&@&NO&5&@&@&NO #?%.DN$_%.DN ..9 <@99E	 	 !*!***4 7;ii@ U#s    Gc                t    |D cg c]%  \  }}|j                         |j                         f' c}}S c c}}w )zprovide deannotation for the various lists of
        pairs, so that using them in hashes doesn't incur
        high-overhead __eq__() comparisons against
        original columns mapped.

        )_deannotate)r   r  r  r  s       r   _deannotate_pairszJoinCondition._deannotate_pairs  s/     @JJtq!!--/2JJJs   *4c                8    g }t        j                  g       g }	 	 	 	 	 	 d fd} j                  |f j                  |ffD ]  \  }}|	 |||         j	                         _         j	                  |       _         j	                  |       _        y )Nc                @    	 	 	 	 	 	 	 	 dfd}t        ||        y )Nc                   d|j                   v r3d|j                   vr%j                  |      rj                  ||f       n@d|j                   v r2d|j                   vr$j                  |      rj                  ||f       | j                  t        j
                  u rXj                  ||      rEd|j                   v rj                  ||f       y d|j                   v rj                  ||f       y y y y )Nr   r   )r  r\  r  operatorr:   eqr  )r  r  r  r  lrpr   s      r   r  z<JoinCondition._setup_pairs.<locals>.go.<locals>.visit_binary  s      2 22 (9(99--d3GGT5M* 1 11 (:(::--e4GGUDM*??ill2t7L7L%8 !E$6$66"))4-8"d&7&77"))5$-8 882r   )r  r   r  r   r  r   r   r   rJ   )joincondr  r  rm  r   s    ` r   goz&JoinCondition._setup_pairs.<locals>.go  s8    9-9(9 *9 	92 !x8r   )rn  r   r  _MutableColumnPairsr   r   )r6   
OrderedSetr   r   rg  r   r   r   )r   
sync_pairssecondary_sync_pairsro  rn  r  rm  s   `     @r   r  zJoinCondition._setup_pairs  s    *,
OOB 	 57	9)	9+	9 	9@ z*!56%
 	% Hj x$	% #'"8"8"=!%!7!7
!C+/+A+A ,
(r   zwweakref.WeakKeyDictionary[ColumnElement[Any], weakref.WeakKeyDictionary[RelationshipProperty[Any], ColumnElement[Any]]]_track_overlapping_sync_targetsc                j   | j                   sy | j                  D cg c]	  \  }}||f c}}| j                  D cg c]	  \  }}||f c}}z   D ]  \  }| j                  vr/t	        j
                  | j                  |i      | j                  <   Dg }| j                     }|j                         D ]  \  }}|j                  j                  r|| j                  j                  vs7|j                  | j                  j                  vsZ| j                  j                  |j                  vs}d| j                  j                  vsd|j                  vs| j                  j                  j                  |j                        r| j                  j                  j                  |j                        r| j                  j                  j                  |j                        r7| j                  j                  j                  |j                        rh| j                  j                  |j                  k7  s1| j                  j                  j                  |j                        r|j!                  ||f        |r~t#        j$                  d| j                  d|dddj'                  t)        fd|D                    dd	j'                  t)        d
 |D                    d| j                  dd       || j                     | j                  <    y c c}}w c c}}w )Nz__*rG  z' will copy column z to column z(, which conflicts with relationship(s): z, c              3  <   K   | ]  \  }}d |d|dd  yw)r  z
' (copies z to rH  Nr   )r4  prfr_to_s      r   r6  zCJoinCondition._warn_for_conflicting_sync_targets.<locals>.<genexpr>v  s&      '"(1S ACC$M'"s   a  . If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="r  c              3  :   K   | ]  \  }}|j                     y wr   )r  )r4  rw  frs      r   r6  zCJoinCondition._warn_for_conflicting_sync_targets.<locals>.<genexpr>{  s     +Mvr2BFF+Ms   z"' to the 'z' relationship.qzyxr{  )r[  r   r   rt  weakrefWeakKeyDictionaryr  r   r  _dispose_calledr   r  r   r  
is_siblingr  r  r6   r   r  sorted)r   from_ry  other_propsprop_to_fromrw  rx  s     `    r   r  z0JoinCondition._warn_for_conflicting_sync_targets,  s      .2-C-C
)eSUCL
 .2-M-M
)eSUCL

 K	MJE3 $>>>--tyy%.@A 44S9 !#CCCH+113 6GBII55dii&A&AAFF$))*=*== IIMM= ")<)<<!5 $		 0 0 ; ;BII F $		 0 0 ; ;BII F $		 0 0 ; ;BII F $		 0 0 ; ;BII F IIMMRVV3#'99#3#3#A#A"))#L $**B95/62 II !II! II & '"5@'" !"  HHV+M+M%MN II14 $7: HM44S9$))DWK	M 

s
   L)L/c                $    | j                  d      S r  _gather_join_annotationsr   s    r   r`  zJoinCondition.remote_columns  s    ,,X66r   c                $    | j                  d      S )Nr  r  r   s    r   r   zJoinCondition.local_columns  s    ,,W55r   c                $    | j                  d      S r  r  r   s    r   ra  z!JoinCondition.foreign_key_columns  s    ,,Y77r   c                    t        | j                  | j                  |            }| j                  +|j	                  | j                  | j                  |             |D ch c]  }|j                          c}S c c}w r   )r   rX  r   r   r   rf  )r   r;  sr  s       r   r  z&JoinCondition._gather_join_annotations  ss     001A1A:N
 )HH44&&

 *++A+++s   !A;c                    t        |      }t        j                  |i       D ch c]4  }|j                  |j                        rt        t        t           |      6 c}S c c}w r   )r   r<   r  issubsetr  r   rA   r   )r   r5  r;  annotation_setr~  s        r   rX  z-JoinCondition._gather_columns_with_annotation  s\     Z  ''3
&&s'7'78 s#S)
 	
 
s   9A c                    | j                   Gt        t        j                  | j                   j                  D cg c]  }|j
                   c}       S t        j                  S c c}w r   )r   	frozenset	itertoolschainr  	proxy_setr6   	EMPTY_SETr   r  s     r   _secondary_lineage_setz$JoinCondition._secondary_lineage_set  sP    >>%t~~7G7G!H!!++!HI  >>! "Is   A$c                8    t        |ddi      } j                   j                   j                  }}}||||z  }n||z  }|rM	 	 	 	 	 	 d
 fdt	        fd|D              }||t        j                  | z  }n|t        j                  | z  }|r||j                  d      }t        |t              }	t        | j                        j                  |	      }
|5t        |t              j                  t        | j                              }	|
j                  |      }nKt        |t         j                  	      }	|+|	j                  t        |t         j                  	             d}
|	j                  |      }|
xs |	}d|_        nd}|||||fS )a7  Given a source and destination selectable, create a
        join between them.

        This takes into account aliasing the join clause
        to reference the appropriate corresponding columns
        in the target objects, as well as the extra child
        criterion, equivalent column sets, etc.

        rN  TNc                    | j                   j                  dd      }|j                  j                  ur2|j                  j                  ur| j
                  vrt        | |      S | S )a  note unrelated columns in the "extra criteria" as either
                should be adapted or not adapted, even though they are not
                part of our "local" or "remote" side.

                see #9779 for this case, as well as #11010 for a follow up

                r  N)r  r  r  r  r  r  r?   )r  r   parentmapper_for_elementr   s      r   mark_exclude_colsz5JoinCondition.join_targets.<locals>.mark_exclude_cols  sg     ,0+<+<+@+@"D,(
 -DII4D4DD0		8H8HHD$?$??)$<<Kr   c              3  >   K   | ]  }t        |d di        yw)should_not_adaptT)annotate_callableNrB   )r4  r  r  s     r   r6  z-JoinCondition.join_targets.<locals>.<genexpr>  s3      #  '.&7 #s   )flat)
exclude_fn)equivalents)r  r  )r  rf   r   re   r   rf   )rE   r   r   r   r7  r5   r;  rR  rG   _local_col_excluderX  r  rW  rT  _remote_col_excluder  )r   r#  rL  r  ra  r  r   r   r   primary_aliasizersecondary_aliasizerr-  r  s   `           @r   r  zJoinCondition.join_targets  s   6 ,7>

 NN %.] "( - ;)K7 ) 8G $ 0 # # +# N ( -.0I I)CHHn,EE$%;;;F	$11%! '4#1G1G'%)* $ %0(5!#5) e%-(,(?(? & !4 < <] K$1#1 $ 6 6%!
 %0%++%-':(,(?(? '+#+44[AK0E4EN(,N%!N
 	
r   c                  
 i 
i }| j                   d urIt        j                  t              | j                  D ]   \  }}|   j                  ||f       |||<   " n5s| j                  D ]
  \  }}|||<    n| j                  D ]
  \  }}|||<    	 	 	 	 	 	 d
fd}| j                  }| j                   st        j                  |i |      }| j                   ;| j                   }rt        j                  |i |      }t        j                  ||      }
D ci c]  }
|   j                  | }	}||	|fS c c}w )Nc                    sd| j                   v srEr| v ss=d| j                   v r/| vr&t        j                  d d | j                  d      | <   |    S y )Nr  r   T)rq  rr  )r  r5   ru  rv  )r  r   bindshas_secondarylookupr  s     r   col_to_bindz5JoinCondition.create_lazy_clause.<locals>.col_to_bindP  sj     '7g6J6J+J$"w&'8)h':N:N.N %'%(]]d',,t&E'N W~%r   )r  r   r   r   r   zOptional[BindParameter[Any]])r   collectionsdefaultdictlistr   r  r   r<   r  r5   r;  r  )r   r  equated_columnsr  r  r  	lazywherer   r~  r  r  r  r  s    `        @@@r   create_lazy_clausez JoinCondition.create_lazy_clause:  s   
 ?AHJ**$6 ,,T2F// '1q	  !Q(%&"' #// '1%&"' // '1%&"'	'	/2	)	 	$ $$	%-> 552{I ) ..M  ( = =!2{! M:I6;<suSz~~s*<<+66 =s   "E ) rS  rk   rT  rk   rU  rk   rV  rk   r   r   r   r   r   r   rW  Optional[_EquivalentColumnMap]rX  r  rY  r   r   r   r   r   rZ  r   r  r  r[  r   r\  zCallable[..., bool]r  r  )r5  ri   r;  r   r   r   r   )r<  z$Callable[[ColumnElement[Any]], bool]r=  r   r   r   )rH   r   rW  r   r   r   )r  _ColumnPairIterabler   rp  )r   r   )r;  r   r   r   )r5  r   r;  zIterable[str]r   r   )r   zFrozenSet[ColumnElement[Any]])Nr   )r#  r   rL  rk   r  r   ra  r   r  r  r   ztTuple[ColumnElement[bool], Optional[ColumnElement[bool]], Optional[FromClause], Optional[ClauseAdapter], FromClause])F)r  r   r   zgTuple[ColumnElement[bool], Dict[str, ColumnElement[Any]], Dict[ColumnElement[Any], ColumnElement[Any]]])0r   r   r   r   r   r  r  r  r	  r  r  r6   r  r  r  r   r  r  r
  r  r)  r+  r  r.  r0  r/  r1  r2  r:  r  r  r  r  r  rg  r  r}  r~  rt  r  r`  r   ra  r  rX  r  r  r  r   r   r   r   r     sp   66$$00##
####!--$$))((''&&// 6:*.7;=A<@(,59 %!0?%3#-3 #-3 ",	3
 !+3 33 (3 53 ;3 :3 #&3 33 3 3  (!3" #3$ .%3j$LL$]~ N N P P 
": ":H 
A A 
@ @)0d2
9,
.
6
KO
	
2B/
b
&

<

8B,1B,<@B,	B,HPd	K-	K		K2
r 	"!!# $ & $TMl 
7 7 
6 6 
8 8,,	 ,
(
7D
	 
 
" " 6::<I
/I
 $I
 	I

 3I
 8I

I
V87r   r   c                  $    e Zd ZdZdZddZddZy)_ColInAnnotationszSerializable object that tests for names in c._annotations.

    TODO: does this need to be serializable anymore?  can we find what the
    use case was for that?

    )namesc                $    t        |      | _        y r   )r  r  )r   r  s     r   r   z_ColInAnnotations.__init__  s    u%
r   c                ^    t        | j                  j                  |j                              S r   )r   r  rs  r  r  s     r   __call__z_ColInAnnotations.__call__  s     DJJ++ANN;<<r   N)r  r   )r  ri   r   r   )r   r   r   r   r   r   r  r   r   r   r  r  u  s     I&=r   r  r  r  r   c                      e Zd ZdZdZy)Relationshipa  Describes an object property that holds a single item or list
    of items that correspond to a related database table.

    Public constructor is the :func:`_orm.relationship` function.

    .. seealso::

        :ref:`relationship_config_toplevel`

    .. versionchanged:: 2.0 Added :class:`_orm.Relationship` as a Declarative
       compatible subclass for :class:`_orm.RelationshipProperty`.

    TN)r   r   r   r   r  r   r   r   r  r    s     Mr   r  c                  (    e Zd ZdZdZ	 edd       Zy)_RelationshipDeclaredz>Relationship subclass used implicitly for declarative mapping.Tc                     y)Nr  r   )r8  s    r   _mapper_property_namez+_RelationshipDeclared._mapper_property_name  s    r   Nr  )r   r   r   r   r  classmethodr  r   r   r   r  r    s"    
 IM r   r  )r   r   r   r   )r  r   r   re   r   r   )r   
__future__r   r  r   dataclassesr7   r2  r  r   r5  r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r}   r   r   _typingr   r   baser   r   r   r    r!   r"   r#   r$   
interfacesr%   r&   r'   r(   r)   r*   r+   r,   r6   r-   r.   r/   r1   r   r2   r3   r4   r5   
inspectionr8   r9   r:   r;   r<   sql._typingr=   r>   sql.annotationr?   sql.elementsr@   rA   sql.utilrC   rD   rE   rF   rG   rH   rI   rK   util.typingrL   rM   rN   TYPE_CHECKINGrO   rP   rQ   rR   rS   rT   rU   rV   clsregistryrW   rX   	decl_baserY   r  rZ   r  r[   queryr\   r  r]   ry  r^   
strategiesr_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   
sql.schemarj   sql.selectablerk   rl   rm   rn   rp   rq   rr   rs   r   _RelationshipArgumentTyper  r   "_RelationshipJoinConditionArgument_RelationshipSecondaryArgumentr  ORMBackrefArgumentDMLColumnRole_ORMColCollectionElement_ORMColCollectionArgumentr   r   r  r   rp  r   r   	dataclassr   r   r   class_logger
Identifiedr   r   r   r  r  r  r  r  r   r   r   <module>r     s   #      	                        * . $ "   &   ! ) / " ! ! & - +  !                3 + + ' ( % ' ( . $ % * + 4 ! 9	$,)&,&,#1/ $&"!/2'04/,,"+13Te3e3e3vS! "HRb\RR##$&   
 " &+	"4	((& " "'#xL 011"  ENc"R*3//0R3C899:U31#6678:  3c4S>&9 ::;  c	  "%&R2334R))*	  v6s;<e/0 u]3%7s9K%KLM mC0-2DDEF5s!3]35G!GHI &( 'wsCx( ' ':  mC6H#6M0N NO 
 6 I
04cnnI
 I
X<
c7 c7L%= =" 'w0BC '2DE r,B"r   