
    3~jq                       U d Z ddlmZ ddlmZ ddlm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!m#Z# erEd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 dWd*Z3dXd,Z4n  ej5        d-          Z3 ej5        d.          Z4ee
         Z6e7Z8ee8d/d0f         Z9ee9d1f         Z:ed/         Z;eed0e7f                  Z< ej=        e>          Z?dYd3Z@d4ZAd5eBd6<   d7ZCd8ZDd9eBd:<   d;ZEd<eBd=<    eFeAeCg          ZG	  eFd> eDeEfD                       ZH	 eGeHz  ZI	  G d? d'e           ZJ G d@ dAeJ          ZK G dB dCeK          ZL eL            eJ_M         G dD dEejN        e e7          ZOdF eHD             eO_P         G dG dHeJ          ZQ G dI dJeJ          ZR G dK dLeK          ZS G dM dNeS          ZT G dO dPee
e
f                   ZU G dQ dReS          ZVer
dXdSZWdZdUZXdS  ej5        d.          ZW ej5        dV          ZXdS )[z>Path tracking utilities, representing mapper graph traversals.    )annotations)reduce)chainN)Any)cast)Dict)Iterator)List)Mapping)Optional)overload)Sequence)Tuple)TYPE_CHECKING)Union   )base)insp_is_mapper_property   )exc)util)visitors)HasCacheKey)Final)Literal)_InternalEntityType)StrategizedProperty)Mapper)RelationshipProperty)AliasedInsp)_CacheKeyTraversalType)BindParameter)anon_map)_LiteralStar)	TypeGuardpathPathRegistryreturnTypeGuard[RootRegistry]c                    d S N r&   s    TC:\Users\server\puls-backend\.venv\Lib\site-packages\sqlalchemy\orm\path_registry.pyis_rootr/   1             !TypeGuard[AbstractEntityRegistry]c                    d S r+   r,   r-   s    r.   	is_entityr4   3   r0   r1   r/   r4   _InternalEntityType[Any]StrategizedProperty[Any]._SerializedPathc                6    t                               |           S r+   )r'   deserializer-   s    r.   _unreduce_pathr:   Q   s    ##D)))r1   *r$   _WILDCARD_TOKEN_sa_defaultrelationshipzFinal[Literal['relationship']]_RELATIONSHIP_TOKENcolumnzFinal[Literal['column']]_COLUMN_TOKENc              #  F   K   | ]}t           t          fD ]}| d | V  dS ):N)r<   _DEFAULT_TOKEN).0wildcard_keysuffixs      r.   	<genexpr>rH   d   s`        "N3  	 f      r1   c                     e Zd ZU dZdZdZdZdZdZdZ	de
d<   de
d<   de
d<   d	e
d
<   de
d<   dej        j        fgZde
d<   dOdZdOdZedPd            ZdQdZdRdZdRd Z	 dSdTd#ZdUd$ZdUd%ZedVd)            ZedWd+            ZedXd-            ZedYd/            ZedZd2            Zd[d5ZedUd6            Zd\d8Zd]d;Zd^d<Zd_d=Ze d`d?            Z!e dad@            Z"dbdAZ#e dcdB            Z$ee dddD                        Z%ee dedG                        Z%e dfdH            Z%e dgdJ            Z&dhdKZ'didMZ(didNZ)d!S )jr'   a  Represent query load paths and registry functions.

    Basically represents structures like:

    (<User mapper>, "orders", <Order mapper>, "items", <Item mapper>)

    These structures are generated by things like
    query options (joinedload(), subqueryload(), etc.) and are
    used to compose keys stored in the query._attributes dictionary
    for various options.

    They are then re-composed at query compile/result row time as
    the query is formed and as rows are fetched, where they again
    serve to compose keys to look up options in the context.attributes
    dictionary, which is copied from query._attributes.

    The path structure has a limited amount of caching, where each
    "root" ultimately pulls from a fixed registry associated with
    the first mapper, that also contains elements for each of its
    property keys.  However paths longer than two elements, which
    are the exception rather than the rule, are generated on an
    as-needed basis.

    r,   Fboolis_unnatural_PathRepresentationr&   natural_pathzOptional[PathRegistry]parentRootRegistryrootr!   _cache_key_traversalotherr   r(   c                    	 |d uo| j         |j        k    S # t          $ r( t          j        dt          |          z             Y dS w xY w)N1Comparison of PathRegistry to %r is not supportedFr&   _path_for_compareAttributeErrorr   warntypeselfrR   s     r.   __eq__zPathRegistry.__eq__   sj    	$Me6M)MM 	 	 	IC;;    55	    .AAc                    	 |d u p| j         |j        k    S # t          $ r( t          j        dt          |          z             Y dS w xY w)NrT   TrU   rZ   s     r.   __ne__zPathRegistry.__ne__   si    	D=HDI1H$HH 	 	 	IC;;    44	r]   Optional[_PathRepresentation]c                    | j         S r+   r-   r[   s    r.   rV   zPathRegistry._path_for_compare   s
    yr1   indexintr5   c                    | j         |         S r+   r-   )r[   rc   s     r.   odd_elementzPathRegistry.odd_element   s    yr1   
attributesDict[Any, Any]keyvalueNonec                X    t                               d|| |           |||| j        f<   d S )Nzset '%s' on path '%s' to '%s')logdebugrM   r[   rg   ri   rj   s       r.   setzPathRegistry.set   s3    		13eDDD/4
C*+,,,r1   c                z    t                               d|| |           |                    || j        f|           d S )Nz$setdefault '%s' on path '%s' to '%s')rm   rn   
setdefaultrM   ro   s       r.   rr   zPathRegistry.setdefault   sA     			8#tUKKKsD$56>>>>>r1   NOptional[Any]c                0    || j         f}||v r||         S |S r+   )rM   ro   s       r.   getzPathRegistry.get   s+     D%&*c?"Lr1   c                *    t          | j                  S r+   lenr&   rb   s    r.   __len__zPathRegistry.__len__   s    49~~r1   c                     t          |           S r+   )idrb   s    r.   __hash__zPathRegistry.__hash__   s    $xxr1   entity_StrPathTokenTokenRegistryc                    d S r+   r,   r[   r}   s     r.   __getitem__zPathRegistry.__getitem__   s    CF3r1   _PathElementTypec                    d S r+   r,   r   s     r.   r   zPathRegistry.__getitem__   s    <?Cr1   slicec                    d S r+   r,   r   s     r.   r   zPathRegistry.__getitem__   s    ADr1   AbstractEntityRegistryc                    d S r+   r,   r   s     r.   r   zPathRegistry.__getitem__   s	     "%r1   r6   PropRegistryc                    d S r+   r,   r   s     r.   r   zPathRegistry.__getitem__   s	     sr1   TUnion[_StrPathToken, int, slice, _InternalEntityType[Any], StrategizedProperty[Any]]aUnion[TokenRegistry, _PathElementType, _PathRepresentation, PropRegistry, AbstractEntityRegistry]c                    t                      r+   )NotImplementedErrorr   s     r.   r   zPathRegistry.__getitem__   s      "###r1   c                *    t          | j                  S r+   rw   rb   s    r.   lengthzPathRegistry.length  s    49~~r1   OIterator[Tuple[_InternalEntityType[Any], Union[str, StrategizedProperty[Any]]]]c              #     K   t          t          | j                  }t          t          |          }t	          dt          |          d          D ]}||         ||dz            fV  d S )Nr   r   r   )r   _OddPathRepresentationr&   _EvenPathRepresentationrangerx   )r[   odd_path	even_pathis       r.   pairszPathRegistry.pairs  sv      
 .	::0(;;	q#h--++ 	0 	0A1+yQ//////	0 	0r1   mapperMapper[Any]c                    t          t          | j                  fdt          dt	                    d          D             D ]}|j                            |          r dS  dS )Nc                     g | ]
}|         S r,   r,   rE   r   _m_paths     r.   
<listcomp>z0PathRegistry.contains_mapper.<locals>.<listcomp>  s    JJJ1GAJJJJr1   r   r   TF)r   r   r&   r   rx   r   isa)r[   r   path_mapperr   s      @r.   contains_mapperzPathRegistry.contains_mapper  sv    -ty99JJJJaWq0I0IJJJ 	 	K!%%f-- tt 5r1   c                    || j         f|v S r+   r-   )r[   rg   ri   s      r.   containszPathRegistry.contains  s    TY:--r1   c                :    t           |                                 ffS r+   )r:   	serializerb   s    r.   
__reduce__zPathRegistry.__reduce__  s     0 0222r1   r7   c                   t          t          |          t          t          |          t          t	          t          d fdt          dt                    d          D             D                       t          d fdt          dt                    d          D             D                       dz                       S )	Nc              3  ^   K   | ](}|j         s|j        r|j        nt          |          V  )d S r+   )	is_mapperis_aliased_classclass_str)rE   ms     r.   rH   z/PathRegistry._serialize_path.<locals>.<genexpr>%  sQ         "#O0BOAHHQ     r1   c                     g | ]
}|         S r,   r,   r   s     r.   r   z0PathRegistry._serialize_path.<locals>.<listcomp>'      LLLQgajLLLr1   r   r   c              3  `   K   | ])}t          |          r|j        nt          |          V  *d S r+   )r   ri   r   )rE   ps     r.   rH   z/PathRegistry._serialize_path.<locals>.<genexpr>)  sO         5Q77CAEESVV     r1   c                     g | ]
}|         S r,   r,   )rE   r   _p_paths     r.   r   z0PathRegistry._serialize_path.<locals>.<listcomp>+  r   r1   r   r+   )r   r   r   listziptupler   rx   )clsr&   r   r   s     @@r.   _serialize_pathzPathRegistry._serialize_path  s    -t44.55  LLLL%3w<<2K2KLLL       LLLL%3w<<2K2KLLL     	
 

 
 	
r1   c                    d
dddt          t          fd|D                        }|r|d         
|d	d         }|S )Nmclsr   r(   c                n    | t           j        vrt          j        | d          nt           j        |          S NT)	configure)	PathToken_internorm_base_inspect_mapped_class)r   s    r.   _deserialize_mapper_tokenzAPathRegistry._deserialize_path.<locals>._deserialize_mapper_token3  s:    
 y000 .ttDDDD&t,r1   ri   c                    |d S |t           j        v rt           j        |         S t          j        | d          }|J |j        |         S r   )r   r   r   r   attrs)r   ri   mps      r.   _deserialize_key_tokenz>PathRegistry._deserialize_path.<locals>._deserialize_key_token<  sR    {t	))) (--3DDIII~~~x}$r1   c                D    g | ]\  }} |           ||          fS r,   r,   )rE   r   ri   r   r   s      r.   r   z2PathRegistry._deserialize_path.<locals>.<listcomp>H  sO       
 "c 21$77..tS99  r1   r   )r   r   r(   r   )r   r   ri   r   r(   r   )r   r   )r   r&   r   r   r   s      @@r.   _deserialize_pathzPathRegistry._deserialize_path1  s    	 	 	 		% 	% 	% 	%     
 &*  

 

  	2!B$Ar1   c                :    | j         }|                     |          S r+   )r&   r   )r[   r&   s     r.   r   zPathRegistry.serializeU  s    y##D)))r1   c                ^    |J |                      |          }|                     |          S r+   )r   coerce)r   r&   r   s      r.   r9   zPathRegistry.deserializeY  s1    !!$''zz!}}r1   CachingEntityRegistryc                    d S r+   r,   r   r   s     r.   
per_mapperzPathRegistry.per_mapper_  s    GJsr1   AliasedInsp[Any]SlotsEntityRegistryc                    d S r+   r,   r   s     r.   r   zPathRegistry.per_mapperc  s    JM#r1   c                d    |j         rt          | j        |          S t          | j        |          S r+   )r   r   rP   r   r   s     r.   r   zPathRegistry.per_mapperg  s3      	9(6:::&sx888r1   rawc                6    dd}t          ||| j                  S )Nprevr'   next_r   r(   c                    | |         S r+   r,   r   r   s     r.   _redz!PathRegistry.coerce.<locals>._redr      ;r1   r   r'   r   r   r(   r'   )r   rP   )r   r   r   s      r.   r   zPathRegistry.coercep  s,    	 	 	 	 dC***r1   c                6    dd}t          ||j        |           S )Nr   r'   r   r   r(   c                    | |         S r+   r,   r   s     r.   r   z"PathRegistry.__add__.<locals>._redy  r   r1   r   )r   r&   )r[   rR   r   s      r.   __add__zPathRegistry.__add__x  s,    	 	 	 	 dEJ---r1   r   c                R    dd                     d | j        D                        dS )Nz	ORM Path[z -> c              3  4   K   | ]}t          |          V  d S r+   r   )rE   elems     r.   rH   z'PathRegistry.__str__.<locals>.<genexpr>  s(      &G&GTs4yy&G&G&G&G&G&Gr1   ])joinr&   rb   s    r.   __str__zPathRegistry.__str__~  s0    J6;;&G&GTY&G&G&GGGJJJJr1   c                0    | j         j         d| j        dS )N())	__class____name__r&   rb   s    r.   __repr__zPathRegistry.__repr__  s     .)::DI::::r1   )rR   r   r(   rJ   r(   r`   )rc   rd   r(   r5   )rg   rh   ri   r   rj   r   r(   rk   r+   )rg   rh   ri   r   rj   rs   r(   r   )r(   rd   )r}   r~   r(   r   )r}   rd   r(   r   )r}   r   r(   rL   )r}   r5   r(   r   )r}   r6   r(   r   )r}   r   r(   r   )r(   r   )r   r   r(   rJ   )rg   rh   ri   r   r(   rJ   )r(   r   )r&   rL   r(   r7   )r&   r7   r(   rL   )r(   r7   r&   r7   r(   r'   )r   r   r(   r   )r   r   r(   r   )r   r5   r(   r   )r   rL   r(   r'   )rR   r'   r(   r'   )r(   r   )*r   
__module____qualname____doc__	__slots__is_tokenr/   
has_entityis_propertyr4   __annotations__r   ExtendedInternalTraversaldp_has_cache_key_listrQ   r\   r_   propertyrV   rf   rp   rr   ru   ry   r|   r   r   r   r   r   r   r   classmethodr   r   r   r9   r   r   r   r   r   r,   r1   r.   r'   r'   {   s         2 IHGJKI%%%%"""" 
3IJ4              X       5 5 5 5? ? ? ? LP           FFF XF??? X?DDD XD% % % X%    X$ $ $ $&    X0 0 0 0   . . . .3 3 3 3 
 
 
 [
$ ! ! ! [!F* * * *    [
 JJJ [ XJMMM [ XM9 9 9 [9 + + + [+. . . .K K K K; ; ; ; ; ;r1   c                  0    e Zd ZU dZded<   ded<   dd	Zd
S )CreatesTokenr,   rJ   r   r/   tokenr~   r(   r   c                    |t           j        vrt          j        d|           |                    dt
                     rt          | |          S t          | j        |          S )Nzinvalid token: rC   )r   r   r   ArgumentErrorendswithr<   r   rP   )r[   r   s     r.   r   zCreatesToken.token  si    	)))#$=e$=$=>>>^^11122 	3 u--- E222r1   N)r   r~   r(   r   )r   r   r   r   r   r   r,   r1   r.   r   r     sD         IMMM3 3 3 3 3 3r1   r   c                  N    e Zd ZdZdZdZdxZZdZdZ	dZ
dZdd	Zdd
ZeseZdS dS )rO   zXRoot registry, defers to mappers so that
    paths are maintained per-root-mapper.

    r,   TFr}   r   r(   ,Union[TokenRegistry, AbstractEntityRegistry]c                    |t           j        v r>t          rt          |t                    sJ t          | t           j        |                   S 	 |j        S # t          $ r t          d|           w xY w)Nz/invalid argument for RootRegistry.__getitem__: )	r   r   r   
isinstancer~   r   _path_registryrW   
IndexErrorr   s     r.   _getitemzRootRegistry._getitem  s     Y&&& 9!&-88888 y'8'@AAA,,!    NfNN  s   A A2c                    | S r+   r,   rb   s    r.   _truncate_recursivez RootRegistry._truncate_recursive  s    r1   N)r}   r   r(   r  )r(   rO   )r   r   r   r   r   inherit_cacher&   rM   r   r   r/   rK   r
  r  r   r   r,   r1   r.   rO   rO     s         
 IMD<JGL         r1   rO   c                  @    e Zd ZU dZded<   	 dd	Zedd            ZdS )r   zcacheable string tokenzMapping[str, PathToken]r   r#   
bindparamsList[BindParameter[Any]]r(   Tuple[Any, ...]c                "    t          |           fS r+   r   )r[   r#   r  s      r.   _gen_cache_keyzPathToken._gen_cache_key  s     D		|r1   r`   c                    d S r+   r,   rb   s    r.   rV   zPathToken._path_for_compare  s    tr1   N)r#   r#   r  r  r(   r  r   )r   r   r   r   r   r  r   rV   r,   r1   r.   r   r     sa           $$$$	   
    X  r1   r   c                .    i | ]}|t          |          S r,   )r   )rE   r   s     r.   
<dictcomp>r    s"    GGGUIe,,GGGr1   c                  `    e Zd ZU dZdZded<   ded<   ddZdZdZddZ	ddZ
ddZeseZdS dS )r   )r   rN   r&   rM   Tr~   r   r   rN   c                    t           j        |         }|| _        || _        |j        |fz   | _        |j        |fz   | _        d S r+   )r   r   r   rN   r&   rM   )r[   rN   r   s      r.   __init__zTokenRegistry.__init__  sE    !%(
K5(*	"/5(:r1   Fr(   Iterator[PathRegistry]c              #    K   | j         }t          |          r| V  d S t          rt          |t                    sJ |j        s@|j                                        D ]$}t          |j         |         | j	                  V  %d S |j        r_t          d|j                  j        rE| V  t          d|j                  j        D ]$}t          |j         |         | j	                  V  %d S | V  d S Nr   )rN   r/   r   r  r   r   r   iterate_to_rootr   r   r   r}   _is_with_polymorphic_with_polymorphic_entitiesr[   rN   mp_entents       r.   generate_for_superclassesz'TokenRegistry.generate_for_superclasses  s;     6?? 	JJJF 	>f&<=====& 	 -7799 G G#FM&$94:FFFFFFG G #	"  #	 JJJ"FM (D D $FM#$6
CCCCCCD D
 JJJJJr1   Iterator[_PathRepresentation]c              #     K   | j         }t          |          r| j        V  d S t          rt	          |t
                    sJ |j                                        D ])}t          |j         |         | j	                  j        V  *|j
        rit          d|j                  j        rO| j        V  t          d|j                  j        D ])}t          |j         |         | j	                  j        V  *d S | j        V  d S r  )rN   r/   rM   r   r  r   r   r  r   r   r   r   r}   r  r  r   s       r.   "_generate_natural_for_superclassesz0TokenRegistry._generate_natural_for_superclasses  sB      6?? 	####F 	>f&<=====m3355 	P 	PFf 5tzBBOOOOO#	$"  #	$ ####"FM (  "&-"4djAAN     ######r1   r}   r   c                d    	 | j         |         S # t          $ r}t          |           |d }~ww xY wr+   )r&   	TypeErrorr	  )r[   r}   errs      r.   r
  zTokenRegistry._getitem%  sE    	39V$$ 	3 	3 	3[))s2	3s    
/*/N)rN   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,   r1   r.   r   r     s         ;IM; ; ; ; JH   6$ $ $ $:3 3 3 3   r1   r   c                  v    e Zd ZU dZdZdZded<   ded<   ded<   ddZddZe	dd            Z
ddZeseZdS dS )r   )proprN   r&   rM   r   r}   r   _wildcard_path_loader_key_default_path_loader_key_loader_keyrK   Tr6   r,  zOptional[Mapper[Any]]r   z"Optional[_InternalEntityType[Any]]r}   rN   r   c                   t          d|d                   }|}|j        j        pt          |j        j                  | _        |j        r|j        r|j        |j                 x}}n|j        rf|j        r_|j        |j        v rQ|d         	                    |j                  }|j        |         }|j        r|j        |j                 }d| _        nP|}nM|j        rF|j        r?|j        |j        ur1|j        
                    |j                  r|j        |j                 }|| _        || _        |j        |fz   | _        |j        |fz   | _        |j        | _        |j        r7t"          rt%          |t&                    sJ |j        | _        |j        | _        nd | _        d | _        d|j        | j        j        z   f| _        | j        j        | _        d| j        f| _        d S )Nr5   r   Tloader)r   rN   rK   rJ   r   inheritsr   _use_mapper_pathwith_polymorphic_mappers_entity_for_mapperr   r,  r&   rM   _links_to_entityr   _is_relationshipr   r  r   r}   _wildcard_tokenr-  r.  r/  )r[   rN   r,  inspnatural_parentsubclass_entitys         r.   r  zPropRegistry.__init__D  s    .r
;;17 #M6 
$M";
 ;
 $ 4	8(= 4	8&,mDK&@@F^^!2	8-2	8 t<<<8>r
8U8UVZVa8b8bO]?3F@ } (!'/E!F$(!!!'!	8%	8 ; ,, $]4;7N	K4')	*74'A/  	 >!$(<=====+DK+DKKDKDK $)";;*
& )-	(J%$d&78r1   r(   c                    d }t          t          | j        d d                             D ]\  }}|| j        u r|}|| S |                     | j        d|dz                       S )Nr   r   r   )	enumeratereversedr&   r,  r   )r[   earliestr   r   s       r.   r  z PropRegistry._truncate_recursive  sv    !(49SbS>":":;; 	 	HAu	!!K;;tyx!|_)<=>>>r1   c                .    | j         J | | j                  S r+   )r}   rb   s    r.   entity_pathzPropRegistry.entity_path  s    {&&&DK  r1   +Union[int, slice, _InternalEntityType[Any]]DUnion[AbstractEntityRegistry, _PathElementType, _PathRepresentation]c                t    t          |t          t          f          r| j        |         S t	          | |          S r+   )r  rd   r   r&   r   r   s     r.   r
  zPropRegistry._getitem  s7     fsEl++ 	59V$$&tV444r1   N)rN   r   r,  r6   )r(   r   r(   r   )r}   rB  r(   rC  )r   r   r   r   r  r   r   r  r  r   rA  r
  r   r   r,   r1   r.   r   r   /  s         I MK""""!!!!....X9 X9 X9 X9t	? 	? 	? 	? ! ! ! X!5 5 5 5   r1   r   c                      e Zd ZU dZdZdZded<   ded<   ded<   ded	<   dd
ZddZe	dd            Z
e	dd            Ze	dd            ZddZddZeseZdS dS )r   )ri   rN   r   r&   r}   rM   T!Union[RootRegistry, PropRegistry]rN   r5   ri   r}   rJ   r   c                   || _         || _        |j        | _        || _        |j        |fz   | _        |j        r| j        s|j        ry|j        d         }|j                            |j                  s|j                            |j                  r|j        |j        fz   | _        d S |j        |j        fz   | _        d S | j        | _        d S )Nr   )	ri   rN   r   r}   r&   rK   rM   r   r   )r[   rN   r}   parent_natural_entitys       r.   r  zAbstractEntityRegistry.__init__  s    
  & 7K6)+	$ ;  	*D1  	*V5H  	* %+$7$;!}  %,  &-11  %+$76=:J$J!!!$*$7)0; %!!! !%	Dr1   r(   c                J    | j                                         | j                 S r+   )rN   r  r}   rb   s    r.   r  z*AbstractEntityRegistry._truncate_recursive	  s    {..00==r1   c                ,    |                      d          S )Nr   )rf   rb   s    r.   root_entityz"AbstractEntityRegistry.root_entity  s    """r1   r'   c                    | S r+   r,   rb   s    r.   rA  z"AbstractEntityRegistry.entity_path  s    r1   r   c                    | j         j        S r+   )r}   r   rb   s    r.   r   zAbstractEntityRegistry.mapper  s    {!!r1   c                    dS )NTr,   rb   s    r.   __bool__zAbstractEntityRegistry.__bool__  s    tr1   r   :Union[_PathElementType, _PathRepresentation, PathRegistry]c                    t          |t          t          f          r| j        |         S |t          j        v r t          | t          j        |                   S t          | |          S r+   )r  rd   r   r&   r   r   r   r   r   s     r.   r
  zAbstractEntityRegistry._getitem  s]     fsEl++ 	.9V$$y((( y'8'@AAAf---r1   NrN   rG  r}   r5   rE  )r(   r5   )r(   r'   )r(   r   )r(   rJ   )r}   r   r(   rQ  )r   r   r   r   r   r4   r   r  r  r   rL  rA  r   rP  r
  r   r   r,   r1   r.   r   r     s        I JI----!!!!$$$$;* ;* ;* ;*z> > > > # # # X#    X " " " X"   . . . .   r1   r   c                      e Zd ZdZdS )r   TN)r   r   r   r  r,   r1   r.   r   r   )  s         MMMr1   r   c                      e Zd Zd
dZddZd	S )_ERDictregistryr   c                    || _         d S r+   )rW  )r[   rW  s     r.   r  z_ERDict.__init__0  s     r1   ri   r   r(   r   c                :    t          | j        |          x| |<   }|S r+   )r   rW  )r[   ri   items      r.   __missing__z_ERDict.__missing__3  s!    's;;;S	Dr1   N)rW  r   )ri   r   r(   r   )r   r   r   r  r[  r,   r1   r.   rV  rV  /  s<        ! ! ! !     r1   rV  c                  H     e Zd ZdZdZd fdZddZddZeseZ	 xZ
S  xZ
S )r   )_cacheTrN   rG  r}   r5   c                t    t                                          ||           t          |           | _        d S r+   )superr  rV  r]  )r[   rN   r}   r   s      r.   r  zCachingEntityRegistry.__init__A  s0    
 	(((dmmr1   ri   r   defaultr(   c                8    | j                             ||          S r+   )r]  pop)r[   ri   r`  s      r.   rb  zCachingEntityRegistry.popI  s    {sG,,,r1   c                    t          |t          t          f          r| j        |         S t          |t                    rt          | |          S | j        |         S r+   )r  rd   r   r&   r   r   r]  r   s     r.   r
  zCachingEntityRegistry._getitemL  sT    fsEl++ 	'9V$$	** 	' v...;v&&r1   rS  )ri   r   r`  r   r(   r   r*  )r   r   r   r   r  r  rb  r
  r   r   __classcell__)r   s   @r.   r   r   9  s         IM$ $ $ $ $ $- - - -' ' ' '     r1   r   c                    d S r+   r,   r-   s    r.   path_is_entityrf  Z  s    ,/Cr1   TypeGuard[PropRegistry]c                    d S r+   r,   r-   s    r.   path_is_propertyri  ^  r0   r1   r   )r&   r'   r(   r)   )r&   r'   r(   r2   r   )r&   r'   r(   rg  )Yr   
__future__r   	functoolsr   	itertoolsr   loggingoperatortypingr   r   r   r	   r
   r   r   r   r   r   r   r    r   r   _typingr   r   r   sqlr   sql.cache_keyr   util.typingr   r   r   
interfacesr   r   r   relationshipsr   r    r!   sql.elementsr"   sql.visitorsr#   r$   r%   r/   r4   
attrgetterr7   r   r~   r   rL   r   r   	getLoggerr   rm   r:   r<   r   rD   r?   rA   	frozenset_UNPREFIXED_TOKENS_PATH_TOKENS_ACCEPTED_TOKENSr'   r   rO   rP   InspectionAttrr   r   r   r   r   r   rV  r   rf  ri  r,   r1   r.   <module>r     sG   E D D " " " " " "                                                                                                   , , , , , ,                   ' ' ' ' ' '       ! ! ! ! ! ! 1,,,,,,//////333333!!!!!!666666,,,,,,''''''******''''''CCCCOOOOO "h!),,G##K00I s)-/II  ,c12  ""<= "5)CS)H#IJ  g!!* * * * !$ # # # #6D  D D D D*2 2 2 2 2Y@AA  y  ,m<    
 &4 G; G; G; G; G;; G; G; G;T3 3 3 3 3< 3 3 3# # # # #< # # #L !LNN     'c   2 HG,GGG	 S S S S SL S S SlH H H H H< H H HVl l l l l\ l l l^    0       d38n       2   >  
:0 0 0 0 MLLLLL )X(55N*x*=99r1   