
    +h                        d 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 Z ej                  d      Z	  G d dej                         Z G d de      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d de      Z G d de      Z ej                  d      Z G d d e      Z G d! d"e      Zy)#zContain the ``AssociationProxy`` class.

The ``AssociationProxy`` is a Python property object which provides
transparent proxied access to the endpoint of an association object.

See the example ``examples/association/proxied_association.py``.

    N   )exc)inspect)orm)util)collections)
interfaces)or_)ColumnOperatorsc                     t        | |fi |S )a  Return a Python property implementing a view of a target
    attribute which references an attribute on members of the
    target.

    The returned value is an instance of :class:`.AssociationProxy`.

    Implements a Python property representing a relationship as a collection
    of simpler values, or a scalar value.  The proxied property will mimic
    the collection type of the target (list, dict or set), or, in the case of
    a one to one relationship, a simple scalar value.

    :param target_collection: Name of the attribute we'll proxy to.
      This attribute is typically mapped by
      :func:`~sqlalchemy.orm.relationship` to link to a target collection, but
      can also be a many-to-one or non-scalar relationship.

    :param attr: Attribute on the associated instance or instances we'll
      proxy for.

      For example, given a target collection of [obj1, obj2], a list created
      by this proxy property would look like [getattr(obj1, *attr*),
      getattr(obj2, *attr*)]

      If the relationship is one-to-one or otherwise uselist=False, then
      simply: getattr(obj, *attr*)

    :param creator: optional.

      When new items are added to this proxied collection, new instances of
      the class collected by the target collection will be created.  For list
      and set collections, the target class constructor will be called with
      the 'value' for the new instance.  For dict types, two arguments are
      passed: key and value.

      If you want to construct instances differently, supply a *creator*
      function that takes arguments as above and returns instances.

      For scalar relationships, creator() will be called if the target is None.
      If the target is present, set operations are proxied to setattr() on the
      associated object.

      If you have an associated object with multiple attributes, you may set
      up multiple association proxies mapping to different attributes.  See
      the unit tests for examples, and for examples of how creator() functions
      can be used to construct the scalar relationship on-demand in this
      situation.

    :param \*\*kw: Passes along any other keyword arguments to
      :class:`.AssociationProxy`.

    )AssociationProxy)target_collectionattrkws      R/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/ext/associationproxy.pyassociation_proxyr      s    h -t:r::    ASSOCIATION_PROXYc                   ^    e Zd ZdZdZeZ	 	 	 	 	 	 ddZd Zd Z	d Z
ddZd	 Zd
 Zd Zd Zy)r   zDA descriptor that presents a read/write view of an object attribute.TNc	                     || _         || _        || _        || _        || _        || _        || _        dt        |       j                  d|dt        |       | _
        |r|| _        yy)a  Construct a new :class:`.AssociationProxy`.

        The :func:`.association_proxy` function is provided as the usual
        entrypoint here, though :class:`.AssociationProxy` can be instantiated
        and/or subclassed directly.

        :param target_collection: Name of the collection we'll proxy to,
          usually created with :func:`_orm.relationship`.

        :param attr: Attribute on the collected instances we'll proxy
          for.  For example, given a target collection of [obj1, obj2], a
          list created by this proxy property would look like
          [getattr(obj1, attr), getattr(obj2, attr)]

        :param creator: Optional. When new items are added to this proxied
          collection, new instances of the class collected by the target
          collection will be created.  For list and set collections, the
          target class constructor will be called with the 'value' for the
          new instance.  For dict types, two arguments are passed:
          key and value.

          If you want to construct instances differently, supply a 'creator'
          function that takes arguments as above and returns instances.

        :param cascade_scalar_deletes: when True, indicates that setting
         the proxied value to ``None``, or deleting it via ``del``, should
         also remove the source object.  Only applies to scalar attributes.
         Normally, removing the proxied target will not remove the proxy
         source, as this object may have other state that is still to be
         kept.

         .. versionadded:: 1.3

         .. seealso::

            :ref:`cascade_scalar_deletes` - complete usage example

        :param getset_factory: Optional.  Proxied attribute access is
          automatically handled by routines that get and set values based on
          the `attr` argument for this proxy.

          If you would like to customize this behavior, you may supply a
          `getset_factory` callable that produces a tuple of `getter` and
          `setter` functions.  The factory is called with two arguments, the
          abstract type of the underlying collection and this proxy instance.

        :param proxy_factory: Optional.  The type of collection to emulate is
          determined by sniffing the target collection.  If your collection
          type can't be determined by duck typing or you'd like to use a
          different collection implementation, you may supply a factory
          function to produce those collections.  Only applicable to
          non-scalar relationships.

        :param proxy_bulk_set: Optional, use with proxy_factory.  See
          the _set() method for details.

        :param info: optional, will be assigned to
         :attr:`.AssociationProxy.info` if present.

         .. versionadded:: 1.0.9

        _N)r   
value_attrcreatorgetset_factoryproxy_factoryproxy_bulk_setcascade_scalar_deletestype__name__idkeyinfo)	selfr   r   r   r   r   r   r"   r   s	            r   __init__zAssociationProxy.__init__c   sn    R "3,*,&<# JtH

 DI r   c                 X    || S | j                  ||      }|r|j                  |      S | S N)_as_instanceget)r#   objclass_insts       r   __get__zAssociationProxy.__get__   s6    >K  -88C= 
 r   c                 \    t        |      }| j                  ||      j                  ||      S r&   )r   r'   set)r#   r)   valuesr*   s       r   __set__zAssociationProxy.__set__   s+    c  -11#v>>r   c                 Z    t        |      }| j                  ||      j                  |      S r&   )r   r'   delete)r#   r)   r*   s      r   
__delete__zAssociationProxy.__delete__   s)    c  -44S99r   c                 &    | j                  ||      S )a  Return the internal state local to a specific mapped class.

        E.g., given a class ``User``::

            class User(Base):
                # ...

                keywords = association_proxy('kws', 'keyword')

        If we access this :class:`.AssociationProxy` from
        :attr:`_orm.Mapper.all_orm_descriptors`, and we want to view the
        target class for this proxy as mapped by ``User``::

            inspect(User).all_orm_descriptors["keywords"].for_class(User).target_class

        This returns an instance of :class:`.AssociationProxyInstance` that
        is specific to the ``User`` class.   The :class:`.AssociationProxy`
        object remains agnostic of its parent class.

        :param class\_: the class that we are returning state for.

        :param obj: optional, an instance of the class that is required
         if the attribute refers to a polymorphic target, e.g. where we have
         to look at the type of the actual destination object to get the
         complete path.

        .. versionadded:: 1.3 - :class:`.AssociationProxy` no longer stores
           any state specific to a particular parent class; the state is now
           stored in per-class :class:`.AssociationProxyInstance` objects.


        )r'   )r#   r*   r)   s      r   	for_classzAssociationProxy.for_class   s    B   --r   c                 2   	 |j                   | j                  dz      }|G| j                  |      }|2t        j                  | ||      }t        || j                  dz   |       nd }||j                  s|j                  |      S |S # t        $ r d }Y ww xY w)N_inst)	__dict__r!   KeyError_calc_ownerAssociationProxyInstance	for_proxysetattr_is_canonical_non_canonical_get_for_object)r#   r*   r)   r+   owners        r   r'   zAssociationProxy._as_instance   s    	??488g#56D
 <$$V,E /99$sK7 2D9D$6$6 55c::K)  	D	s   B BBc                     	 t        |      }|j                  j                  j                  S # t        j
                  $ r Y y w xY wr&   )r   mapperclass_managerr*   r   NoInspectionAvailable)r#   
target_clsinsps      r   r:   zAssociationProxy._calc_owner  sE    		4:&D ;;,,333 (( 	
 	s   - AAc                     | j                   t        j                        fd}|t        u r	fd}||fS fd}||fS )Nc                     |  |       S d S r&    target_getters    r   getterz0AssociationProxy._default_getset.<locals>.getter      &,&876?BdBr   c                      t        | |       y r&   r=   okvr   s      r   setterz0AssociationProxy._default_getset.<locals>.setter$      4#r   c                      t        | |       y r&   rP   rR   rT   r   s     r   rU   z0AssociationProxy._default_getset.<locals>.setter)  rV   r   r   operator
attrgetterdictr#   collection_classrM   rU   rL   r   s       @@r   _default_getsetz AssociationProxy._default_getset  sN    %%d+	C t#$ v~$ v~r   c                 <    d| j                   d| j                  dS )NzAssociationProxy(z, ))r   r   r#   s    r   __repr__zAssociationProxy.__repr__.  s    ""OO
 	
r   )NNNNNFr&   )r   
__module____qualname____doc__is_attributer   extension_typer$   r,   r0   r3   r5   r'   r:   r_   rc   rI   r   r   r   r   ]   sS    NL&N $Wr
?:!.F24&
r   r   c                   r   e Zd ZdZd ZdZ	 ed        Zed        Zd Z	e
d        Zd Zed	        Zej                  d
        Ze
d        Ze
d        Ze
d        Zej                  d        Zej                  d        Ze
d        Zd Zd Ze
d        Zd Zd Zd Zd Zd Zd ZddZ ddZ!ddZ"d Z#y)r;   a  A per-class object that serves class- and object-specific results.

    This is used by :class:`.AssociationProxy` when it is invoked
    in terms of a specific class or instance of a class, i.e. when it is
    used as a regular Python descriptor.

    When referring to the :class:`.AssociationProxy` as a normal Python
    descriptor, the :class:`.AssociationProxyInstance` is the object that
    actually serves the information.   Under normal circumstances, its presence
    is transparent::

        >>> User.keywords.scalar
        False

    In the special case that the :class:`.AssociationProxy` object is being
    accessed directly, in order to get an explicit handle to the
    :class:`.AssociationProxyInstance`, use the
    :meth:`.AssociationProxy.for_class` method::

        proxy_state = inspect(User).all_orm_descriptors["keywords"].for_class(User)

        # view if proxy object is scalar or not
        >>> proxy_state.scalar
        False

    .. versionadded:: 1.3

    c                     || _         |j                  | _        || _        |j                  | _        d | _        || _        || _        y r&   )parentr!   owning_classr   r^   target_classr   )r#   rk   rl   rm   r   s        r   r$   z!AssociationProxyInstance.__init__S  sA    ::(!'!9!9 $($r   Nc                 n   |j                   }|j                  }t        j                  |      j	                  |      }t        |t        j                        s t        j                  t        d      d        |j                  j                  }	 | j                  ||      }| j                  |||||      S # t        $ r t        ||||      cY S t         $ r^}	t        j                  t#        j$                  d|j&                  d|j                  d|j&                  d|	      |	       Y d }	~	y d }	~	ww xY w)NzEassociation proxy to a non-relationship intermediary is not supportedreplace_contextzRAssociation proxy received an unexpected error when trying to retreive attribute ".z" from class "z": )from_)r   r   r   class_mapperget_property
isinstanceRelationshipPropertyr   raise_NotImplementedErrorrB   r*   _cls_unwrap_target_assoc_proxy_construct_for_assocAttributeError!AmbiguousAssociationProxyInstance	Exceptionr   InvalidRequestErrorr   )
clsrk   rl   parent_instancer   r   proprm   target_assocerrs
             r   r<   z"AssociationProxyInstance.for_proxye  s-   "44&&
-::;LM $ 8 89KK#4 !% {{))	==jL6 ++flL* 1  	 5lJ   	KK'' %--))$--	  	s   B5 5D4D4AD//D4c                     |t        ||||      S t        ||      }t        |d      st        ||||      S |j                  }|rt        ||||      S t        ||||      S )N_is_internal_proxy)ObjectAssociationProxyInstancegetattrhasattrr|   _impl_uses_objectsColumnAssociationProxyInstance)r   r   rk   rl   rm   r   r   	is_objects           r   rz   z-AssociationProxyInstance._construct_for_assoc  s     #1lJ  |Z0t124lJ  ++	1lJ  2lJ r   c                 r    t        j                  | j                        j                  | j                        S r&   )r   rs   rl   rt   r   rb   s    r   _get_propertyz&AssociationProxyInstance._get_property  s/     1 12??""
 	
r   c                 6    | j                         j                  S r&   )r   
comparatorrb   s    r   _comparatorz$AssociationProxyInstance._comparator  s    !!#...r   c                     t        d      )NzqThe association proxy can't be used as a plain column expression; it only works inside of a comparison expressionrx   rb   s    r   __clause_element__z+AssociationProxyInstance.__clause_element__  s    !J
 	
r   c                 L    t        ||      }t        |t        t        f      r|S y r&   )r   ru   r   r;   )r   rm   r   r   s       r   ry   z7AssociationProxyInstance._cls_unwrap_target_assoc_proxy  s'    |Z0d-/GHIKr   c                 N    | j                  | j                  | j                        S r&   )ry   rm   r   rb   s    r   _unwrap_target_assoc_proxyz3AssociationProxyInstance._unwrap_target_assoc_proxy  s$    22t
 	
r   c                 B    t        | j                  | j                        S )zThe 'remote' class attribute referenced by this
        :class:`.AssociationProxyInstance`.

        .. seealso::

            :attr:`.AssociationProxyInstance.attr`

            :attr:`.AssociationProxyInstance.local_attr`

        )r   rm   r   rb   s    r   remote_attrz$AssociationProxyInstance.remote_attr  s     t(($//::r   c                 B    t        | j                  | j                        S )zThe 'local' class attribute referenced by this
        :class:`.AssociationProxyInstance`.

        .. seealso::

            :attr:`.AssociationProxyInstance.attr`

            :attr:`.AssociationProxyInstance.remote_attr`

        )r   rl   r   rb   s    r   
local_attrz#AssociationProxyInstance.local_attr  s     t(($*@*@AAr   c                 2    | j                   | j                  fS )a  Return a tuple of ``(local_attr, remote_attr)``.

        This attribute was originally intended to facilitate using the
        :meth:`_query.Query.join` method to join across the two relationships
        at once, however this makes use of a deprecated calling style.

        To use :meth:`_sql.select.join` or :meth:`_orm.Query.join` with
        an association proxy, the current method is to make use of the
        :attr:`.AssociationProxyInstance.local_attr` and
        :attr:`.AssociationProxyInstance.remote_attr` attributes separately::

            stmt = (
                select(Parent).
                join(Parent.proxied.local_attr).
                join(Parent.proxied.remote_attr)
            )

        A future release may seek to provide a more succinct join pattern
        for association proxy attributes.

        .. seealso::

            :attr:`.AssociationProxyInstance.local_attr`

            :attr:`.AssociationProxyInstance.remote_attr`

        )r   r   rb   s    r   r   zAssociationProxyInstance.attr  s    : !1!122r   c                 `    | j                         j                   }|r| j                          |S )zsReturn ``True`` if this :class:`.AssociationProxyInstance`
        proxies a scalar relationship on the local side.)r   uselist_initialize_scalar_accessors)r#   scalars     r   r   zAssociationProxyInstance.scalar  s/    
 '')111--/r   c                 ~    | j                         j                  j                  | j                        j                   S r&   )r   rB   rt   r   r   rb   s    r   _value_is_scalarz)AssociationProxyInstance._value_is_scalar  s1     ""$VLL1W	
r   c                     t               r&   r   rb   s    r   _target_is_objectz*AssociationProxyInstance._target_is_object  s    !##r   c                     | j                   j                  r | j                   j                  d |       \  }}n| j                   j                  d       \  }}||c| _        | _        y r&   )rk   r   r_   _scalar_get_scalar_set)r#   r(   set_s      r   r   z5AssociationProxyInstance._initialize_scalar_accessors  sS    ;;%%224>IC33D9IC-0$*$*r   c                     | j                   t        j                        fd}|t        u r	fd}||fS fd}||fS )Nc                     |  |       S d S r&   rI   rJ   s    r   rM   z8AssociationProxyInstance._default_getset.<locals>.getter'  rN   r   c                     t        | |      S r&   rP   rQ   s      r   rU   z8AssociationProxyInstance._default_getset.<locals>.setter,      q$**r   c                     t        | |      S r&   rP   rX   s     r   rU   z8AssociationProxyInstance._default_getset.<locals>.setter1  r   r   rY   r]   s       @@r   r_   z(AssociationProxyInstance._default_getset#  sN    %%d+	C t#+ v~+ v~r   c                 .    | j                   j                  S r&   )rk   r"   rb   s    r   r"   zAssociationProxyInstance.info6  s    {{r   c                    || S | j                   r't        || j                        }| j                  |      S 	 t        || j                        \  }}}t        |      |k(  rt        |       |k(  r| j                  J |S | j                  t        || j                              \  | _        }t        || j                  t        |      t        |       |f       |S # t        $ r Y fw xY wr&   )r   r   r   r   r!   r    r^   r{   _new_lazy_collectionr=   )r#   r)   rK   
creator_idself_idproxys         r   r(   zAssociationProxyInstance.get:  s    ;K;;S$"8"89F##F++	! .5S$((-C*
GU c7j(RX-@00<<< L+/99 d&<&<=,(D!5 CBsGRXu#=>L " s   C 	C&%C&c                    | j                   r| j                  j                  r| j                  j                  n| j                  }t	        || j
                        }|!|y t        || j
                   ||             y | j                  ||       |/| j                  j                  rt        || j
                  d        y y y | j                  |      }| j                  J ||ur|j                  | |       y y r&   )r   rk   r   rm   r   r   r=   r   r   r(   r^   _bulk_replace)r#   r)   r/   r   rK   r   s         r   r.   zAssociationProxyInstance.setS  s    ;; ;;&& ##&& 
 S$"8"89F~>T33WV_E  0>dkk&H&HC!7!7> 'I> HHSME((444F"##D&1 #r   c                     | j                   | j                  |d        | j                  r.t        || j                        }|t        || j                         t        || j                         y r&   )rl   r:   r   r   r   delattrr   r#   r)   rK   s      r   r2   zAssociationProxyInstance.deletei  s[    $S$';;S$"8"89F!0T++,r   c                    | j                   j                  r| j                   j                  n| j                  }t        j                   |             }| j                   j
                  r*|| j                   j                  ||| j                  |       fS | j                   j                  r | j                   j                  ||       \  }}n| j                   j                  |      \  }}|t        u r|t        |||||       fS |t        u r|t        |||||       fS |t        u r|t        |||||       fS t        j                   d| j"                  j$                  d| j&                  d      )Nz=could not guess which interface to use for collection_class "z" backing "z6"; specify a proxy_factory and proxy_bulk_set manually)rk   r   rm   r   duck_type_collectionr   r   r   r_   list_AssociationListr\   _AssociationDictr.   _AssociationSetr   ArgumentErrorr^   r   r   )r#   lazy_collectionr   r^   rM   rU   s         r   r   zAssociationProxyInstance._news  sj   #';;#6#6DKKD<M<M 	  44_5FG;;$$ ))#Wdoot  ;;%%![[778H$ONFF![[889IJNFFt#  #Wffd  %  #Wffd  $ #Wffd  ## ((1143I3IK r   c                 j   | j                   j                  r| j                   j                  ||       y | j                  t        u r|j	                  |       y | j                  t
        u r|j                  |       y | j                  t        u r|j                  |       y t        j                  d      )NzEno proxy_bulk_set supplied for custom collection_class implementation)
rk   r   r^   r   extendr\   updater.   r   r   )r#   r   r/   s      r   _setzAssociationProxyInstance._set  s    ;;%%KK&&uf5""d*LL ""d*LL ""c)LL ##2 r   c                 v   | j                   j                  xr | j                   j                  xs | j                  }| j                   j                  r*| j                   j                  | j                  |       \  }}n(| j                   j                  | j                        \  }}||_        ||_        ||_        y r&   )rk   r   rm   r   r^   r_   rM   rU   )r#   r   r   rM   rU   s        r   _inflatez!AssociationProxyInstance._inflate  s    KK7DKK$7$7L4;L;L 	 ;;%%![[77%%tNFF "[[889N9NONFFr   c                    |j                  dd       }| j                  }|/ |j                  dd|i|}| j                  j                  |      S | j                  r4t        | j                  | j                        } |j                  |fi |}n2|rt        j                  d      |r|t        j                  d      |}| j                  j                  |      S )Nis_has	criterionzJCan't apply keyword arguments to column-targeted association proxy; use ==zINon-empty has() not allowed for column-targeted association proxy; use ==rI   )
popr   _criterion_existsr   r   r   rm   r   r   r   )r#   r   kwargsr   r   innerr   
value_exprs           r   r   z*AssociationProxyInstance._criterion_exists  s    Hd+66#2L22 #'-E ##55e<<!!4,,doo>D///	DVDJ''0  I1''@ 
 #J11*==r   c                     | j                   9| j                  r-| j                  r| j                  rt	        j
                  d       | j                  d|dd|S )a!  Produce a proxied 'any' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`
        and/or :meth:`.RelationshipProperty.Comparator.has`
        operators of the underlying proxied attributes.

        z9'any()' not implemented for scalar attributes. Use has().Fr   r   rI   r   r   r   r   r   r~   r   r#   r   r   s      r   anyzAssociationProxyInstance.any  sg     **2KK++t/D/D))N  &t%% 

17
 	
r   c                     | j                   9| j                  r| j                  r!| j                  st	        j
                  d       | j                  d|dd|S )a!  Produce a proxied 'has' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`
        and/or :meth:`.RelationshipProperty.Comparator.has`
        operators of the underlying proxied attributes.

        z4'has()' not implemented for collections.  Use any().Tr   rI   r   r   s      r   haszAssociationProxyInstance.has  sg     **2&&t/D/D))I  &t%% 

06
 	
r   c                 N    | j                   j                  d| j                  dS )N(ra   )	__class__r   rk   rb   s    r   rc   z!AssociationProxyInstance.__repr__  s    >>22DKK@@r   r&   )$r   rd   re   rf   r$   rm   classmethodr<   rz   r   propertyr   r   ry   r   memoized_propertyr   r   r   r   r   r   r   r   r_   r"   r(   r.   r2   r   r   r   r   r   r   rc   rI   r   r   r;   r;   5  se   :% L / /b  .

 / /
   

 

 ; ; B B 3 3< 
  

 
 $ $7&    22,-.` >:
(
(Ar   r;   c                   x     e Zd ZdZdZd Z fdZd Zd ZddZ	ddZ
ej                  d	        Zd
 Zd Z xZS )r|   zcan :class:`.AssociationProxyInstance` where we cannot determine
    the type of target object.
    Fc                     t        d| j                  j                  d| j                  d| j                  d| j
                  d	      )NzAssociation proxy rq   z refers to an attribute 'z'' that is not directly mapped on class ze; therefore this operation cannot proceed since we don't know what type of object is referred towards)r{   rl   r   r   r   rm   rb   s    r   
_ambiguousz,AmbiguousAssociationProxyInstance._ambiguous  s>     !!**&&!!	
 	
r   c                 2    || S t         t        |   |      S r&   )superr|   r(   )r#   r)   r   s     r   r(   z%AmbiguousAssociationProxyInstance.get   s     ;K:DEcJJr   c                 $    | j                          y r&   r   r#   r)   s     r   __eq__z(AmbiguousAssociationProxyInstance.__eq__&      r   c                 $    | j                          y r&   r   r   s     r   __ne__z(AmbiguousAssociationProxyInstance.__ne__)  r   r   c                 $    | j                          y r&   r   r   s      r   r   z%AmbiguousAssociationProxyInstance.any,  r   r   c                 $    | j                          y r&   r   r   s      r   r   z%AmbiguousAssociationProxyInstance.has/  r   r   c                     i S r&   rI   rb   s    r   _lookup_cachez/AmbiguousAssociationProxyInstance._lookup_cache2  s	    
 	r   c                 6   |lt        || j                        }|T	 t        |      }|j                  }|j                  }|| j
                  vr| j                  ||       	 | j
                  |   S | S # t        $ r Y | S w xY w# t        j                  $ r Y | S w xY wr&   )
r   r   r   rB   r*   r   _populate_cacher9   r   rD   )r#   r   
actual_objrF   rB   instance_classs         r   r?   z?AmbiguousAssociationProxyInstance._non_canonical_get_for_object9  s    & $2H2HIJ%":.D "[[F%+]]N%T-?-??,,^VD#11.AA  $   00  s#   B  A1 1	A>=A>BBc                    t        j                  | j                        j                  | j                        }|j                  |j                        r`|}	 | j                  || j                        }| j                  || j                  | j                  || j                        | j                  |<   y y # t        $ r Y y w xY wr&   )r   rs   rl   rt   r   isarB   ry   r   rz   rk   r   r{   )r#   r   rB   r   rm   r   s         r   r   z1AmbiguousAssociationProxyInstance._populate_cacheP  s     1 12??""
 ::dkk")L#BB $//  6:5N5N KK%% OO6"">2 # " s   B5 5	C Cr&   )r   rd   re   rf   r>   r   r(   r   r   r   r   r   r   r   r?   r   __classcell__)r   s   @r   r|   r|     sR     M
K 
 .r   r|   c                   *    e Zd ZdZdZdZd Zd Zd Zy)r   zEan :class:`.AssociationProxyInstance` that has an object as a target.Tc                 6   | j                   }|?| j                  j                  |j                  s|j	                  |            S ||k(        S | j
                  r`| j                  rT| j                  sH| j                  j                  t        | j                  | j                        j	                  |            S | j
                  r-| j                  r!| j                  rt        j                  d       | j                  j                  di | j                  |iS )aa  Produce a proxied 'contains' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`,
        :meth:`.RelationshipProperty.Comparator.has`,
        and/or :meth:`.RelationshipProperty.Comparator.contains`
        operators of the underlying proxied attributes.
        z<contains() doesn't apply to a scalar object endpoint; use ==rI   )r   r   r   r   containsr   r   r   r   rm   r   r   r~   )r#   r)   r   s      r   r   z'ObjectAssociationProxyInstance.containsm  s    66###55#** %%c*  "S(  ""))##''))4??;DDSI  ##8M8M))N 
 64##55O#8NOOr   c                     |?t         | j                  j                  di | j                  |i| j                  d k(        S  | j                  j                  di | j                  |iS NrI   )r
   r   r   r   r   s     r   r   z%ObjectAssociationProxyInstance.__eq__  sm     ;$  $$>'=>  D( 
 (4##''A4??C*@AAr   c                 z    | j                   j                  t        | j                  | j                        |k7        S r&   )r   r   r   rm   r   r   s     r   r   z%ObjectAssociationProxyInstance.__ne__  s6     ##D%%t73>
 	
r   N)	r   rd   re   rf   r   r>   r   r   r   rI   r   r   r   r   g  s"    OMPB	B
r   r   c                   $    e Zd ZdZdZdZd Zd Zy)r   zVan :class:`.AssociationProxyInstance` that has a database column as a
    target.
    FTc                     | j                  | j                  j                  t        j                  |            }|t        || j                  d k(        S |S r&   )r   r   operaterZ   eqr
   r   )r#   otherexprs      r   r   z%ColumnAssociationProxyInstance.__eq__  sP    %%$$X[[%8
 =tT--566Kr   c                 `    | j                   | j                  j                  |g|i |      S r&   )r   r   r   )r#   opr   r   s       r   r   z&ColumnAssociationProxyInstance.operate  s5    %%$D$$R:%:6:
 	
r   N)r   rd   re   rf   r   r>   r   r   rI   r   r   r   r     s     M
r   r   c                   $    e Zd Zd Zd Zd Zd Zy)r   c                      || _         || _        y r&   rk   rK   r   s      r   r$   z_lazy_collection.__init__  s    r   c                 B    t        | j                  | j                        S r&   )r   rk   rK   rb   s    r   __call__z_lazy_collection.__call__  s    t{{DKK00r   c                 4    | j                   | j                  dS )N)r)   rK   r  rb   s    r   __getstate__z_lazy_collection.__getstate__  s    {{dkk::r   c                 ,    |d   | _         |d   | _        y )Nr)   rK   r  r#   states     r   __setstate__z_lazy_collection.__setstate__  s    ElHor   N)r   rd   re   r$   r  r  r  rI   r   r   r   r     s    1;&r   r   c                   F    e Zd Zd Z ed       Zd Zd ZeZd Z	d Z
d Zy)	_AssociationCollectionc                 J    || _         || _        || _        || _        || _        y)a  Constructs an _AssociationCollection.

        This will always be a subclass of either _AssociationList,
        _AssociationSet, or _AssociationDict.

        lazy_collection
          A callable returning a list-based collection of entities (usually an
          object attribute managed by a SQLAlchemy relationship())

        creator
          A function that creates new target entities.  Given one parameter:
          value.  This assertion is assumed::

            obj = creator(somevalue)
            assert getter(obj) == somevalue

        getter
          A function.  Given an associated object, return the 'value'.

        setter
          A function.  Given an associated object and a value, store that
          value on the object.

        N)r   r   rM   rU   rk   )r#   r   r   rM   rU   rk   s         r   r$   z_AssociationCollection.__init__  s(    2  /r   c                 "    | j                         S r&   )r   rb   s    r   <lambda>z_AssociationCollection.<lambda>  s     4 4 6 r   c                 ,    t        | j                        S r&   lencolrb   s    r   __len__z_AssociationCollection.__len__      488}r   c                 ,    t        | j                        S r&   )boolr  rb   s    r   __bool__z_AssociationCollection.__bool__  s    DHH~r   c                 4    | j                   | j                  dS )Nrk   r   r  rb   s    r   r  z#_AssociationCollection.__getstate__  s    ++$:N:NOOr   c                 b    |d   | _         |d   | _        | j                   j                  |        y )Nrk   r   )rk   r   r   r	  s     r   r  z#_AssociationCollection.__setstate__  s-    Ho$%67T"r   c                 H    | j                          |j                  | |       y r&   )clearr   )r#   assoc_proxyr/   s      r   r   z$_AssociationCollection._bulk_replace  s    

v&r   N)r   rd   re   r$   r   r  r  r  __nonzero__r  r  r   rI   r   r   r  r    s5    > 6
7C KP#
'r   r  c                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd'dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!e!Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z( e) e*       jW                               D ]M  \  Z,Z- e.e-      se-j                   e,k(  se-j                  r, e/e)e,      s6 e0e)e,      j                  e-_        O [,[-y&)(r   z(Generic, converting, list-to-list proxy.c                 $    | j                  |      S r&   r   r#   values     r   _createz_AssociationList._create      ||E""r   c                 $    | j                  |      S r&   rM   r#   object_s     r   _getz_AssociationList._get      {{7##r   c                 &    | j                  ||      S r&   rU   )r#   r+  r%  s      r   r   z_AssociationList._set  s    {{7E**r   c                     t        |t              s| j                  | j                  |         S | j                  |   D cg c]  }| j                  |       c}S c c}w r&   )ru   slicer,  r  )r#   indexmembers      r   __getitem__z_AssociationList.__getitem__  sH    %'99TXXe_--48HHUOD&DIIf%DDDs    Ac                    t        |t              s | j                  | j                  |   |       y |j                  t        |       }n4|j                  dk  rt        |       |j                  z   }n|j                  }|j                  xs d}|j                  xs d}t        t        |j                  xs d||            }|dk(  r+|D ]  }| |=  |}|D ]  }| j                  ||       |dz  } y t        |      t        |      k7  r#t        dt        |      dt        |            t        ||      D ]$  \  }}| j                  | j                  |   |       & y )Nr      z#attempt to assign sequence of size z to extended slice of size )ru   r1  r   r  stopr  stepstartr   rangeinsert
ValueErrorzip)	r#   r2  r%  r7  r8  r9  rngiitems	            r   __setitem__z_AssociationList.__setitem__  s=   %'IIdhhuou-zz!4ya4y5::-zz::?DKK$1EuU[[-AtT:;Cqy $AU$! DKK4(FA u:S)$7:5z3s8M   #3 1GAtIIdhhqk401r   c                     | j                   |= y r&   r  r#   r2  s     r   __delitem__z_AssociationList.__delitem__2  s    HHUOr   c                 R    | j                   D ]  }| j                  |      |k(  s y yNTFr  r,  r#   r%  r3  s      r   __contains__z_AssociationList.__contains__5  .    hh 	Fyy E)	 r   c                 d    | j                   || D cg c]  }| j                  |       c}S c c}w r&   rH  )r#   r9  endr3  s       r   __getslice__z_AssociationList.__getslice__<  s*    04s0CDf		&!DDDs   -c                 h    |D cg c]  }| j                  |       }}|| j                  || y c c}w r&   r&  r  )r#   r9  rM  r/   rT   memberss         r   __setslice__z_AssociationList.__setslice__?  s2    ,23q4<<?33%s 4s   /c                 "    | j                   ||= y r&   rC  )r#   r9  rM  s      r   __delslice__z_AssociationList.__delslice__C  s    HHU3Yr   c              #   T   K   | j                   D ]  }| j                  |        yw)zIterate over proxied values.

        For the actual domain objects, iterate over .col instead or
        just use the underlying collection directly from its property
        on the parent.
        NrH  r#   r3  s     r   __iter__z_AssociationList.__iter__F  s-      hh 	$F))F##	$   &(c                 `    | j                   }| j                  |      }|j                  |       y r&   )r  r&  append)r#   r%  r  r@  s       r   rZ  z_AssociationList.appendR  s%    hh||E"

4r   c                     t        t        j                  fdt        |             D cg c]  }d c}      S c c}w )Nc                     | k(  S r&   rI   )rT   r%  s    r   r  z(_AssociationList.count.<locals>.<lambda>\  s    a5j r   r6  )sumr   itertools_filteriter)r#   r%  r   s    ` r   countz_AssociationList.countW  sA     ..($t* 
 	
s   	;c                 4    |D ]  }| j                  |        y r&   )rZ  )r#   r/   rT   s      r   r   z_AssociationList.extenda  s     	AKKN	r   c                 B    | j                  |      g| j                  || y r&   rP  )r#   r2  r%  s      r   r;  z_AssociationList.inserte  s    !%e!4 5ur   c                 V    | j                  | j                  j                  |            S r&   )rM   r  r   rD  s     r   r   z_AssociationList.poph  s    {{488<<.//r   c                 f    t        |       D ]  \  }}||k(  s| j                  |=  y  t        d      )Nzvalue not in list)	enumerater  r<  )r#   r%  r?  vals       r   removez_AssociationList.removek  s<    o 	FAse|HHQK	 ,--r   c                     t         )z#Not supported, use reversed(mylist)r   rb   s    r   reversez_AssociationList.reverser  
     "!r   c                     t         )z!Not supported, use sorted(mylist)r   rb   s    r   sortz_AssociationList.sortw  rj  r   c                 H    | j                   dt        | j                         = y )Nr   )r  r  rb   s    r   r  z_AssociationList.clear|  s    HHQTXX&'r   c                     t        |       |k(  S r&   r   r#   r   s     r   r   z_AssociationList.__eq__      DzU""r   c                     t        |       |k7  S r&   ro  rp  s     r   r   z_AssociationList.__ne__  rq  r   c                     t        |       |k  S r&   ro  rp  s     r   __lt__z_AssociationList.__lt__      DzE!!r   c                     t        |       |k  S r&   ro  rp  s     r   __le__z_AssociationList.__le__  rq  r   c                     t        |       |kD  S r&   ro  rp  s     r   __gt__z_AssociationList.__gt__  ru  r   c                     t        |       |k\  S r&   ro  rp  s     r   __ge__z_AssociationList.__ge__  rq  r   c                 @    t        j                  t        |       |      S r&   )r   cmpr   rp  s     r   __cmp__z_AssociationList.__cmp__      xxT
E**r   c                 `    	 t        |      }t        |       |z   S # t        $ r	 t        cY S w xY wr&   r   	TypeErrorNotImplementedr#   iterabler   s      r   __add__z_AssociationList.__add__  s8    	"NE DzE!!  	"!!	"    --c                 `    	 t        |      }|t        |       z   S # t        $ r	 t        cY S w xY wr&   r  r  s      r   __radd__z_AssociationList.__radd__  s8    	"NE tDz!!  	"!!	"r  c                 J    t        |t              st        S t        |       |z  S r&   )ru   intr  r   r#   ns     r   __mul__z_AssociationList.__mul__  s     !S!!!DzA~r   c                 (    | j                  |       | S r&   )r   )r#   r  s     r   __iadd__z_AssociationList.__iadd__  s    Hr   c                     t        |t              st        S |dk(  r| j                          | S |dkD  r | j	                  t        |       |dz
  z         | S Nr   r6  )ru   r  r  r  r   r   r  s     r   __imul__z_AssociationList.__imul__  sR    
 !S!!!6JJL  UKKT
a!e,-r   c                 :     t        |       j                  |g| S r&   )r   r2  )r#   r@  argss      r   r2  z_AssociationList.index  s    tDz,t,,r   c                     t        |       S r&   ro  rb   s    r   copyz_AssociationList.copy  s    Dzr   c                 *    t        t        |             S r&   )reprr   rb   s    r   rc   z_AssociationList.__repr__  s    DJr   c                 D    t        dt        |       j                  z        Nz%s objects are unhashabler  r   r   rb   s    r   __hash__z_AssociationList.__hash__      3d4j6I6IIJJr   N))1r   rd   re   rf   r&  r,  r   r4  rA  rE  rJ  rN  rR  rT  rW  rZ  r`  r   r;  r   rg  ri  rl  r  r   r   rt  rw  ry  r{  r~  r  r  r  __rmul__r  r  r2  r  rc   r  r   localsitems	func_namefunccallabler   r   rI   r   r   r   r     s%   2#$+E1<E& 


60."
"
(##"#"#+""
 H- K   01 <	4TN*LLi("43;;DL< 	4r   r   _NotProvidedc                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd%dZd%dZd Zej4                  rd Zd Zd Zd Zd Znd Zd Ze fdZ!d  Z"d! Z#d" Z$d# Z%d$ Z& e' e(       j?                               D ]M  \  Z)Z* e+e*      se*j                   e)k(  se*j                  r, e,e-e)      s6 e.e-e)      j                  e*_        O [)[*y)&r   z(Generic, converting, dict-to-dict proxy.c                 &    | j                  ||      S r&   r#  r#   r!   r%  s      r   r&  z_AssociationDict._create  s    ||C''r   c                 $    | j                  |      S r&   r)  r*  s     r   r,  z_AssociationDict._get  r-  r   c                 (    | j                  |||      S r&   r/  )r#   r+  r!   r%  s       r   r   z_AssociationDict._set  s    {{7C//r   c                 >    | j                  | j                  |         S r&   r,  r  r#   r!   s     r   r4  z_AssociationDict.__getitem__  s    yy#''r   c                     || j                   v r!| j                  | j                   |   ||       y | j                  ||      | j                   |<   y r&   )r  r   r&  r  s      r   rA  z_AssociationDict.__setitem__  s=    $((?IIdhhsmS%0 LLe4DHHSMr   c                     | j                   |= y r&   rC  r  s     r   rE  z_AssociationDict.__delitem__  s    HHSMr   c                     || j                   v S r&   rC  r  s     r   rJ  z_AssociationDict.__contains__      dhhr   c                     || j                   v S r&   rC  r  s     r   has_keyz_AssociationDict.has_key  r  r   c                 H    t        | j                  j                               S r&   )r_  r  keysrb   s    r   rW  z_AssociationDict.__iter__  s    DHHMMO$$r   c                 8    | j                   j                          y r&   r  r  rb   s    r   r  z_AssociationDict.clear      r   c                     t        |       |k(  S r&   r\   rp  s     r   r   z_AssociationDict.__eq__  rq  r   c                     t        |       |k7  S r&   r  rp  s     r   r   z_AssociationDict.__ne__  rq  r   c                     t        |       |k  S r&   r  rp  s     r   rt  z_AssociationDict.__lt__   ru  r   c                     t        |       |k  S r&   r  rp  s     r   rw  z_AssociationDict.__le__  rq  r   c                     t        |       |kD  S r&   r  rp  s     r   ry  z_AssociationDict.__gt__  ru  r   c                     t        |       |k\  S r&   r  rp  s     r   r{  z_AssociationDict.__ge__	  rq  r   c                 @    t        j                  t        |       |      S r&   )r   r}  r\   rp  s     r   r~  z_AssociationDict.__cmp__  r  r   c                 F    t        t        | j                                     S r&   )r  r\   r  rb   s    r   rc   z_AssociationDict.__repr__  s    D&''r   Nc                 0    	 | |   S # t         $ r |cY S w xY wr&   )r9   r#   r!   defaults      r   r(   z_AssociationDict.get  s%    	9 	N	s    c                 j    || j                   vr!| j                  ||      | j                   |<   |S | |   S r&   )r  r&  r  s      r   
setdefaultz_AssociationDict.setdefault  s5    dhh LLg6DHHSMN9r   c                 6    | j                   j                         S r&   )r  r  rb   s    r   r  z_AssociationDict.keys  s    xx}}r   c                 .      fd j                   D        S )Nc              3   ^   K   | ]$  }|j                  j                  |         f & y wr&   r  .0r!   r#   s     r   	<genexpr>z-_AssociationDict.iteritems.<locals>.<genexpr>%  '     HS$))DHHSM23H   *-rC  rb   s   `r   	iteritemsz_AssociationDict.iteritems$      HtxxHHr   c                 .      fd j                   D        S )Nc              3   Z   K   | ]"  }j                  j                  |          $ y wr&   r  r  s     r   r  z._AssociationDict.itervalues.<locals>.<genexpr>(  "     ADIIdhhsm,A   (+rC  rb   s   `r   
itervaluesz_AssociationDict.itervalues'      AAAr   c                 6    | j                   j                         S r&   )r  iterkeysrb   s    r   r  z_AssociationDict.iterkeys*  s    88$$&&r   c                 z    | j                   j                         D cg c]  }| j                  |       c}S c c}w r&   )r  r/   r,  rV  s     r   r/   z_AssociationDict.values-  s*    48HHOO4EF&DIIf%FFFs   8c                 h    | D cg c]"  }|| j                  | j                  |         f$ c}S c c}w r&   r  )r#   rS   s     r   r  z_AssociationDict.items0  s,    9=>AQ		$((1+./>>>s   '/c                 .      fd j                   D        S )Nc              3   ^   K   | ]$  }|j                  j                  |         f & y wr&   r  r  s     r   r  z)_AssociationDict.items.<locals>.<genexpr>6  r  r  rC  rb   s   `r   r  z_AssociationDict.items5  r  r   c                 .      fd j                   D        S )Nc              3   Z   K   | ]"  }j                  j                  |          $ y wr&   r  r  s     r   r  z*_AssociationDict.values.<locals>.<genexpr>9  r  r  rC  rb   s   `r   r/   z_AssociationDict.values8  r  r   c                     |t         u r| j                  j                  |      }n| j                  j                  ||      }| j                  |      S r&   )r  r  r   r,  )r#   r!   r  r3  s       r   r   z_AssociationDict.pop;  s?    l"XX\\#&FXX\\#w/Fyy  r   c                 h    | j                   j                         }|d   | j                  |d         fS r  )r  popitemr,  )r#   r@  s     r   r  z_AssociationDict.popitemB  s0    xx!Q47+,,r   c                 X   t        |      dkD  rt        dt        |      z        t        |      dk(  r2|d   }t        |d      r|D ]
  }||   | |<    n	 |D ]
  \  }}|| |<    	 |D ]
  \  }}	|	| |<    y # t        $ r*}t	        j
                  t        d      |       Y d }~>d }~ww xY w)Nr6  z+update expected at most 1 arguments, got %ir   r  z4dictionary update sequence requires 2-element tuplesro   )r  r  r   r<  r   rw   )
r#   ar   
seq_or_mapr@  rS   rT   r   r!   r%  s
             r   r   z_AssociationDict.updateF  s    q6A:=AF  Vq[1J z6*& 2D!+D!1DJ2
 * $1"#Q$  	JCDI	 " KK"8 ), s   A6 6	B)? B$$B)c                    t        |       }|j                  |xs d      }t        |xs d      j                  |      }|j                  |      }|j                         xs dD ]  \  }}||v r|| |<   ||v s|| |<    |D ]  }| |=  y r   )r.   intersection
differencer  )	r#   r  r/   existing	constants	additionsremovalsr!   r3  s	            r   r   z_AssociationDict._bulk_replacec  s    t9))&,B7	"%00;	&&y1!<<>/R 	#KCi"S		!"S			#  	CS		r   c                 4    t        | j                               S r&   )r\   r  rb   s    r   r  z_AssociationDict.copyr  s    DJJL!!r   c                 D    t        dt        |       j                  z        r  r  rb   s    r   r  z_AssociationDict.__hash__u  r  r   r&   )/r   rd   re   rf   r&  r,  r   r4  rA  rE  rJ  r  rW  r  r   r   rt  rw  ry  r{  r~  rc   r(   r  r  r   py2kr  r  r  r/   r  r  r   r  r   r   r  r  r   r  r  r  r  r   r\   r   rI   r   r   r   r     s%   2($0(5%##"#"#+( yy	I	B	'	G	?
	I	B  , !-:"K   01 <	4TN*LLi("43;;DL< 	4r   r   c                      e Zd ZdZd Zd Zd Zd ZeZd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd ZeZd ZeZd Zd Zd ZeZd Zd Zd ZeZd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d% Z, e- e.       j_                               D ]M  \  Z0Z1 e2e1      se1j                   e0k(  se1j                  r, e3e4e0      s6 e5e4e0      j                  e1_        O [0[1y&)'r   z&Generic, converting, set-to-set proxy.c                 $    | j                  |      S r&   r#  r$  s     r   r&  z_AssociationSet._create  r'  r   c                 $    | j                  |      S r&   r)  r*  s     r   r,  z_AssociationSet._get  r-  r   c                 ,    t        | j                        S r&   r  rb   s    r   r  z_AssociationSet.__len__  r  r   c                     | j                   ryyrG  rC  rb   s    r   r  z_AssociationSet.__bool__  s    88r   c                 R    | j                   D ]  }| j                  |      |k(  s y yrG  rH  rI  s      r   rJ  z_AssociationSet.__contains__  rK  r   c              #   T   K   | j                   D ]  }| j                  |        yw)zIterate over proxied values.

        For the actual domain objects, iterate over .col instead or just use
        the underlying collection directly from its property on the parent.

        NrH  rV  s     r   rW  z_AssociationSet.__iter__  s-      hh 	$F))F##	$rX  c                 b    || vr+| j                   j                  | j                  |             y y r&   )r  addr&  r$  s     r   r  z_AssociationSet.add  s(    HHLLe,- r   c                     | j                   D ]3  }| j                  |      |k(  s| j                   j                  |        y  y r&   )r  r,  discardrI  s      r   r  z_AssociationSet.discard  s;    hh 	Fyy E)  (	r   c                     | j                   D ]3  }| j                  |      |k(  s| j                   j                  |        y  t        |      r&   )r  r,  r  r9   rI  s      r   rg  z_AssociationSet.remove  sG    hh 	Fyy E)  (	 uor   c                     | j                   st        d      | j                   j                         }| j                  |      S )Nzpop from an empty set)r  r9   r   r,  rV  s     r   r   z_AssociationSet.pop  s3    xx233yy  r   c                 4    |D ]  }| j                  |        y r&   )r  r#   r   r%  s      r   r   z_AssociationSet.update  s     	EHHUO	r   c                 :   t        |       }|j                  |xs d      }t        |xs d      j                  |      }|j                  |      }| j                  }| j                  }|xs dD ]  }	|	|v r	 ||	       |	|v s ||	        |D ]
  }	 ||	        y r   )r.   r  r  r  rg  )
r#   r  r/   r  r  r  r  appenderremoverr3  s
             r   r   z_AssociationSet._bulk_replace  s    t9))&,B7	"%00;	&&y188++l 	!F" 9$ 		!  	FFO	r   c                 n    t        j                  | |      st        S |D ]  }| j                  |        | S r&   )r   _set_binops_check_strictr  r  r  s      r   __ior__z_AssociationSet.__ior__  s7    33D%@!! 	EHHUO	r   c                 *    t        t        |             S r&   )r.   r_  rb   s    r   r   z_AssociationSet._set  s    4:r   c                 6    t        |       j                  |      S r&   )r.   unionrp  s     r   r  z_AssociationSet.union  s    4yu%%r   c                 6    t        |       j                  |      S r&   )r.   r  rp  s     r   r  z_AssociationSet.difference      4y##E**r   c                 4    |D ]  }| j                  |        y r&   )r  r  s      r   difference_updatez!_AssociationSet.difference_update  s     	 ELL	 r   c                 n    t        j                  | |      st        S |D ]  }| j                  |        | S r&   )r   r  r  r  r  s      r   __isub__z_AssociationSet.__isub__  s8    33D%@!! 	 ELL	 r   c                 6    t        |       j                  |      S r&   )r.   r  rp  s     r   r  z_AssociationSet.intersection  s    4y%%e,,r   c                     | j                  |      t        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        y r&   )r  r.   rg  r  r#   r   wanthaverg  r  r%  s          r   intersection_updatez#_AssociationSet.intersection_update  s`    &&u-s4ydTk4$; 	EKK	 	EHHUO	r   c                     t        j                  | |      st        S | j                  |      t	        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        | S r&   )r   r  r  r  r.   rg  r  r  s          r   __iand__z_AssociationSet.__iand__  s{    33D%@!!&&u-s4ydTk4$; 	EKK	 	EHHUO	r   c                 6    t        |       j                  |      S r&   )r.   symmetric_differencerp  s     r   r  z$_AssociationSet.symmetric_difference  s    4y--e44r   c                     | j                  |      t        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        y r&   )r  r.   rg  r  r  s          r   symmetric_difference_updatez+_AssociationSet.symmetric_difference_update  s`    ..u5s4ydTk4$; 	EKK	 	EHHUO	r   c                     t        j                  | |      st        S | j                  |      t	        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        | S r&   )r   r  r  r  r.   rg  r  r  s          r   __ixor__z_AssociationSet.__ixor__"  s{    33D%@!!..u5s4ydTk4$; 	EKK	 	EHHUO	r   c                 6    t        |       j                  |      S r&   )r.   issubsetrp  s     r   r  z_AssociationSet.issubset/  s    4y!!%((r   c                 6    t        |       j                  |      S r&   )r.   
issupersetrp  s     r   r  z_AssociationSet.issuperset2  r	  r   c                 8    | j                   j                          y r&   r  rb   s    r   r  z_AssociationSet.clear5  r  r   c                     t        |       S r&   r.   rb   s    r   r  z_AssociationSet.copy8  s    4yr   c                     t        |       |k(  S r&   r"  rp  s     r   r   z_AssociationSet.__eq__;      4yE!!r   c                     t        |       |k7  S r&   r"  rp  s     r   r   z_AssociationSet.__ne__>  r$  r   c                     t        |       |k  S r&   r"  rp  s     r   rt  z_AssociationSet.__lt__A      4y5  r   c                     t        |       |k  S r&   r"  rp  s     r   rw  z_AssociationSet.__le__D  r$  r   c                     t        |       |kD  S r&   r"  rp  s     r   ry  z_AssociationSet.__gt__G  r'  r   c                     t        |       |k\  S r&   r"  rp  s     r   r{  z_AssociationSet.__ge__J  r$  r   c                 *    t        t        |             S r&   )r  r.   rb   s    r   rc   z_AssociationSet.__repr__M  s    CIr   c                 D    t        dt        |       j                  z        r  r  rb   s    r   r  z_AssociationSet.__hash__P  r  r   N)6r   rd   re   rf   r&  r,  r  r  r   rJ  rW  r  r  rg  r   r   r   r  r   r  __or__r  __sub__r  r  r  __and__r  r  r  __xor__r  r  r  r  r  r  r   r   rt  rw  ry  r{  rc   r  r   r  r  r  r  r  r   r.   r   rI   r   r   r   r     s?   0#$ K	.!$& F+ G - G5 #G)+""!"!"K   01 ;	4TN*LLY'"3	2::DL; 	4r   r   )rf   rZ    r   r   r   r   r   r	   sqlr
   sql.operatorsr   r   symbolr   InspectionAttrInfor   objectr;   r|   r   r   r   r  r   r  r   r   rI   r   r   <module>r7     s            +4;n  DKK 34 U
z44 U
pSAv SAlY(@ Yx7
%= 7
t
-
4&v & 4'V 4'nL- L^ t{{>*l- l^X, Xr   