
    [ho                       U d Z ddlmZ ddlmZ ddlZddlZddlZddlZddlm	Z	 ddlm
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl m"Z" ddl m#Z# ddl m$Z$ ddl m%Z% ddlm&Z& ddlm'Z' d d!lm(Z( d d"lm)Z* d d#lm+Z+ d d$lm,Z, d dlmZ d d%l,m-Z- d d&l,m.Z. d d'l/m0Z0 d d(l1m2Z2 d d)l1m3Z3 d d*l1m4Z4 ej        rdd+l5m6Z6 dd,l5m7Z7 dd-lm8Z8 dd.lm9Z9 dd/lm:Z: dd0l;m<Z< dd1l=m>Z> dd2l?m@Z@ dd3lAmBZB dd4lAmCZC dd5lDmEZE d d6lFmGZG d d7lHmIZI d d8lJmKZK d d9lJmLZL d d:l/mMZM d d;l/mNZN d d<lOmPZP d d=lQmRZR d d>lSmTZT d d?l1mUZU d d@l1mVZV d dAl1mWZW d dBl1mXZX  edCe	D          ZY edEe	D          ZZ G dF dGe$eY                   Z[ee\dHdIdJdKf         Z] edLe	D          Z^ ej_                    Z`dMeadN<    G dO dPe#e^         e"e[e^                   Zb G dQ dRebeY         eeY                   Zc G dS dTe[eY                   Zd G dU dVe[eY                   Ze G dW dXeeeY         eeY                   ZfdS )YzDescriptor properties are more "auxiliary" properties
that exist as configurational elements, but don't participate
as actively in the load/persist ORM loop.

    )annotations)is_dataclassN)Any)Callable)Dict)List)NoReturn)Optional)Sequence)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )
attributes)util)_DeclarativeMapped)LoaderCallableStatus)Mapped)PassiveFlag)SQLORMOperations)_AttributeOptions)_IntrospectsAnnotations)_MapsColumns)MapperProperty)PropComparator)	_none_set)de_stringify_annotation   )event)exc)schema)sql
expression)	operators)BindParameter)get_args)
is_fwd_ref)	is_pep593)_InstanceDict)_RegistryType)History)InstrumentedAttribute)QueryableAttribute)ORMCompileState)_ClassScanMapperConfig)Mapper)ColumnProperty)MappedColumn)InstanceState)
Connection)Row)_DMLColumnArgument)	_InfoType)
ClauseList)ColumnElement)OperatorType)Column)Select)_AnnotationScanType)CallableReference)DescriptorReference)RODescriptorReference_T)bound_PTc                  R    e Zd ZU dZdZded<   dZdZded<   ej	        fddZ
ddZdS )DescriptorPropertyzO:class:`.MapperProperty` which proxies access to a
    user-defined descriptor.NOptional[str]docFzDescriptorReference[Any]
descriptorstateInstanceState[Any]dict_r,   passiver   returnr.   c                    t                      N)NotImplementedError)selfrL   rN   rO   s       n/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/orm/descriptor_props.pyget_historyzDescriptorProperty.get_historyf   s     "###    mapperMapper[Any]Nonec                       G fddt           j                  } j        =t          j         j        d           }                     j        |          r| _         j        )d fd}d fd	}d fd
}t          |||           _         t          j         j                   j	        j         j         j         fd j
                   } | j                  |_        j                             j        |           d S )Nc                  Z    e Zd ZdZdZdZed fd            ZddZe	j
        fd fdZdS )7DescriptorProperty.instrument_class.<locals>._ProxyImplFTrP   boolc                    j         S rR   )uses_objects)rT   props    rU   r`   zDDescriptorProperty.instrument_class.<locals>._ProxyImpl.uses_objectsv   s    ((rW   keystrc                    || _         d S rR   rb   )rT   rb   s     rU   __init__z@DescriptorProperty.instrument_class.<locals>._ProxyImpl.__init__z   s    rW   rL   rM   rN   r,   rO   r   r.   c                2                         |||          S rR   )rV   )rT   rL   rN   rO   ra   s       rU   rV   zCDescriptorProperty.instrument_class.<locals>._ProxyImpl.get_history}   s     ''ug>>>rW   NrP   r^   )rb   rc   rL   rM   rN   r,   rO   r   rP   r.   )__name__
__module____qualname__accepts_scalar_loaderload_on_unexpire
collectionpropertyr`   rf   r   PASSIVE_OFFrV   )ra   s   rU   
_ProxyImplr]   q   s        $)!#J) ) ) ) ) X)    (3'>	? ? ? ? ? ? ? ? ?rW   rr   objr   valuerP   rZ   c                4    t          | j        |           d S rR   )setattrname)rs   rt   rT   s     rU   fsetz1DescriptorProperty.instrument_class.<locals>.fset   s    TY.....rW   c                2    t          | j                   d S rR   )delattrrw   rs   rT   s    rU   fdelz1DescriptorProperty.instrument_class.<locals>.fdel   s    TY'''''rW   c                .    t          | j                  S rR   )getattrrw   r{   s    rU   fgetz1DescriptorProperty.instrument_class.<locals>.fget   s    sDI...rW   )r   rx   r|   c                 .                                    S rR   )_comparator_factory)rX   rT   s   rU   <lambda>z5DescriptorProperty.instrument_class.<locals>.<lambda>   s    D,,V44 rW   )rJ   original_property)rs   r   rt   r   rP   rZ   )rs   r   rP   rZ   )rs   r   rP   r   )r   AttributeImplrK   r~   class_rb   _is_userland_descriptorrp   create_proxied_attributeparentrJ   implclass_managerinstrument_attribute)	rT   rX   rr   descrx   r|   r   
proxy_attrra   s	   ``      @rU   instrument_classz#DescriptorProperty.instrument_classn   s}   	? 	? 	? 	? 	? 	? 	?1 	? 	? 	?( ?"6=$(D99D--dh== '"&?"/ / / / / /( ( ( ( ( (/ / / / / / 'Dt$GGGDOIZ8IIKHO44444"
 
 

 %*TX..
11$(JGGGGGrW   ri   rX   rY   rP   rZ   )rj   rk   rl   __doc__rJ   __annotations__r`   _links_to_entityr   rq   rV   r    rW   rU   rH   rH   [   s             CL((((  +6	$ $ $ $ $2H 2H 2H 2H 2H 2HrW   rH   z
Column[_T]zMappedColumn[_T]zInstrumentedAttribute[_T]z
Mapped[_T]_CCzFweakref.WeakKeyDictionary[Type[Any], Callable[[Any], Tuple[Any, ...]]]_composite_gettersc                  
    e Zd ZU dZded<   ded<   ded<   ded	<   	 d\d
ddd
d
d
dd] fdZd^ fd!Zd_d%Zd`d&Z e	            Z
d`d'Z ej        d(          dad8            Zd`d9Z ej        d(           ej        d:          dbd;                        Zej        dcd=            Zej         ej        d>          ddd@                        Zej         ej        d>          dedB                        ZedfdD            ZedgdF            Z ej        d>          d`dG            Zd`dHZej        dhdJ            ZdidLZej        fdjdTZdkdVZ  G dW dXe!j"        e#                   Z$ G dY dZe%e&                   Z'dld[Z( xZ)S )mCompositePropertyzDefines a "composite" mapped attribute, representing a collection
    of columns as one attribute.

    :class:`.CompositeProperty` is constructed using the :func:`.composite`
    function.

    .. seealso::

        :ref:`mapper_composite`

    z$Union[Type[_CC], Callable[..., _CC]]composite_classz#Tuple[_CompositeAttrType[Any], ...]attrsz=CallableReference[Optional[Callable[[_CC], Tuple[Any, ...]]]]_generated_composite_accessorzType[Comparator[_CC]]comparator_factoryNF)attribute_optionsactive_historydeferredgroupr   info_class_or_attrCUnion[None, Type[_CC], Callable[..., _CC], _CompositeAttrType[Any]]_CompositeAttrType[Any]r   Optional[_AttributeOptions]r   r^   r   r   rI   Optional[Type[Comparator[_CC]]]r   Optional[_InfoType]kwargsr   c                  t                                          |           t          |t          t          t
          j        f          r|f|z   | _        d | _        n|| _        || _        || _	        || _
        || _        ||n| j        j        | _        d | _        || j                            |           t%          j        |            |                                  |                                  d S N)r   )superrf   
isinstancer   rc   r$   r<   r   r   r   r   r   	__class__
Comparatorr   r   r   updater   set_creation_order_create_descriptor_init_accessor)rT   r   r   r   r   r   r   r   r   r   r   s             rU   rf   zCompositeProperty.__init__   s     	+<===nvsC4E&FGG 	(*U2DJ#'D  #1D DJ, 
 "- * 	
 .2*IT"""%%%!!!rW   rX   rY   rP   rZ   c                r    t                                          |           |                                  d S rR   )r   r   _setup_event_handlers)rT   rX   r   s     rU   r   z"CompositeProperty.instrument_class   s3      (((""$$$$$rW   rt   r   Tuple[Any, ...]c                    | j         r|                      |          S 	 |j        } |            S # t          $ r(}t          j        d| j        j         d          |d }~ww xY w)NzComposite class zX is not a dataclass and does not define a __composite_values__() method; can't get state)r   __composite_values__AttributeErrorsa_excInvalidRequestErrorr   rj   )rT   rt   accessoraes       rU   _composite_values_from_instancez1CompositeProperty._composite_values_from_instance   s    - 	"55e<<<	" 5  xzz! "   0/t';'D / / /  	s   / 
A!#AA!c                .    |                                   dS )zwInitialization which occurs after the :class:`.Composite`
        has been associated with its parent mapper.

        N)_setup_arguments_on_columnsrT   s    rU   do_initzCompositeProperty.do_init  s    
 	((*****rW   c                ^     d
 fdd fd}d fd}t          ||           _        d	S )ztCreate the Python descriptor that will serve as
        the access point on instances of the mapped class.

        instancer   rP   c                    t          j                   }t          j                   }j        |vru fdj        D             }j        |vrY|j        t          j        |          s> j        | |j        <   |j        j	        
                    |j        j        g           |                    j        d           S )Nc                0    g | ]}t          |          S r   )r~   ).0rb   r   s     rU   
<listcomp>zFCompositeProperty._create_descriptor.<locals>.fget.<locals>.<listcomp>  s0       /2GHc**  rW   )r   instance_dictinstance_staterb   _attribute_keysr   
issupersetr   managerdispatchrefresh_COMPOSITE_FGETget)r   rN   rL   valuesrT   s   `   rU   r   z2CompositeProperty._create_descriptor.<locals>.fget  s    ,X66E-h77Exu$$   6:6J   85((I)1Ef1M1M)&:d&:F&CE$(OM*22t3dhZ   99TXt,,,rW   rt   rZ   c                
   t          j        |           }t          j        |           }|j        	j                 }|j        j        r |           }n%|                    	j        t          j	                  }|j        j
        D ]} |||||j                  }||	j        <   |	j        D ]}t          | |d            d S t          	j        	                    |                    D ]\  }}t          | ||           d S rR   )r   r   r   r   rb   r   _active_historyr   r   NO_VALUEsetr   r   rv   zipr   )
r   rt   rN   rL   attrpreviousfnrb   r   rT   s
           rU   rx   z2CompositeProperty._create_descriptor.<locals>.fset1  s,   ,X66E-h77E=*D}, N4>> 99TX/C/LMMm' > >5%49==#E$(O}/ 1 1CHc400001 1 #&(88??# # 2 2JC Hc51111	2 2rW   c                   t          j        |           }t          j        |           }|j        j                 }|j        j        r' |           }|                    j        d            n%|                    j        t          j	                  }|j        j                 }|j        
                    |||j                   j        D ]}t          | |d            d S rR   )r   r   r   r   rb   r   r   popr   r   remover   r   rv   )r   rL   rN   r   r   rb   r   rT   s         rU   r|   z2CompositeProperty._create_descriptor.<locals>.fdelH  s    -h77E,X66E=*D}, N4>>		$(D)))) 99TX/C/LMM=*DM  $)<<<+ - -#t,,,,- -rW   N)r   r   rP   r   )r   r   rt   r   rP   rZ   )r   r   rP   rZ   )rp   rK   )rT   rx   r|   r   s   `  @rU   r   z$CompositeProperty._create_descriptor  s    	- 	- 	- 	- 	- 	-6	2 	2 	2 	2 	2 	2 	2.	- 	- 	- 	- 	- 	- 	-  #4t44rW   sqlalchemy.orm.properties	decl_scanr2   registryr-   cls	Type[Any]originating_modulerb   rc   mapped_containerOptional[Type[Mapped[Any]]]
annotationOptional[_AnnotationScanType]extracted_mapped_annotationis_dataclass_fieldc
                   t           j        j        j        }
| j        ||                     ||           |}t          |          rt          |          d         }|r| j        t          |t                    st          |d          rV|At          |d          r|j        nt          |          }t          j        d| d| d          t          |||d          }|| _        t!          | j                  r|                     ||||           nA| j        D ]9}t          ||
t&          j        f          r|j        t          j        d	          :|                                  d S )
Nr   T)check_generic__forward_arg__zCan't use forward ref z9 for composite class argument; set up the type as Mapped[])include_genericzIComposite class column arguments must be named unless a dataclass is used)r   	preloadedorm_propertiesr5   r   _raise_for_requiredr+   r)   r   rc   r*   hasattrr   r   ArgumentErrorr   r   _setup_for_dataclassr   r#   r>   rw   r   )rT   r   r   r   r   rb   r   r   r   r   r5   argumentstr_argr   s                 rU   declarative_scanz"CompositeProperty.declarative_scanZ  s    ~4A (+3$$S#....X 	-))!,H 	,,4(C(( J- - -  &- #8->??+00 ]] 
 !.P P PELP P P   3#5t   $,D ,-- 	%%h5GMMMM
  tlFM%BCC	) .5   	rW   c                0   t          | j                  rt          | j        d          srt          j        | j                  }t          j        d |j                                        D              t          |j                  dk    rfd| _
        n| _
        | j        lt          | j        t                    rT| j        t          vrH| j
        | j
        t          | j        <   d S t          | j        d          rd t          | j        <   d S d S d S d S d S )Nr   c                    g | ]	}|j         
S r   )rw   )r   ps     rU   r   z4CompositeProperty._init_accessor.<locals>.<listcomp>  s    ;;;Q!&;;;rW   r   c                     |           fS rR   r   )rs   getters    rU   r   z2CompositeProperty._init_accessor.<locals>.<lambda>  s    &&++ rW   c                *    |                                  S rR   r   )rs   s    rU   r   z2CompositeProperty._init_accessor.<locals>.<lambda>  s     8 8 : : rW   )r   r   r   inspect	signatureoperator
attrgetter
parametersr   lenr   r   typer   )rT   inspr   s     @rU   r   z CompositeProperty._init_accessor  sD   ,-- 
	<g "87
 7
 
	< $T%9::D(;;$/"8"8":":;;;F 4?##q((5O5O5O5O225;2  ,4/66 -$,>>>1=6 #4#7888 -/EFF :: #4#7888 -,,,>> rW   zsqlalchemy.orm.decl_basec                   t           j        j        j        }t           j        j        }t          j        | j                  }t          j	        |j
                                        | j                  D ]\  }}	|Kt          j        dt          | j                   d| j        j         dt          |j
                             |	 |            }	| xj        |	fz  c_        t#          |	|          r%|	                    |||||j        |j                   t#          |	t*          j                  r|                    |j        |	           d S )Nznumber of composite attributes z3 exceeds that of the number of attributes in class  )r   r   r   r5   orm_decl_baser   r   r   	itertoolszip_longestr  r   r   r   r   r  rj   r   declarative_scan_for_compositerw   r   r#   r>   _undefer_column_name)
rT   r   r   r   rb   r5   	decl_baser  paramr   s
             rU   r   z&CompositeProperty._setup_for_dataclass  sw    ~4AN0	 !566$0O""$$dj
 
 	A 	AKE4 }*N4:N N +4N N 8;4?7K7KN N   |#|~~

tg%

$-- 
A33&J$    D&-00 A..uz4@@@3	A 	ArW   !Sequence[QueryableAttribute[Any]]c                *      fd j         D             S )Nc                N    g | ]!}t          j        j        |j                  "S r   )r~   r   r   rb   r   ra   rT   s     rU   r   z:CompositeProperty._comparable_elements.<locals>.<listcomp>  s*    MMM$*DH55MMMrW   propsr   s   `rU   _comparable_elementsz&CompositeProperty._comparable_elements  s    MMMM$*MMMMrW   zorm.propertiesSequence[MapperProperty[Any]]c                "   g }t           j        j        j        }| j        D ]}t          |t                    r| j                            |d          }nyt          |t          j
                  r| j        j        |         }nLt          ||          r| j        j        |j                 }n$t          |t          j                  r|j        }nd }t          |t                     st#          j        d|          |                    |           |S )NF)_configure_mapperszYComposite expects Column objects or mapped attributes/attribute names as arguments, got: )r   r   r   r5   r   r   rc   r   get_propertyr#   r>   _columntopropertycolumnr   r/   rp   r   r   r   append)rT   r  r5   r   ra   s        rU   r  zCompositeProperty.props  s    ~4AJ 	 	D$$$ 	{///OOD&-00 {4T:D,// {4T[AD*"BCC }dN33 *NEIN N  
 LLrW   Sequence[Column[Any]]c                V    t           j        j        j        fd| j        D             S )Nc                z    g | ]7}t          |t          j        f          t          |          r|j        n|8S r   )r   r#   r>   r  )r   ar5   s     rU   r   z-CompositeProperty.columns.<locals>.<listcomp>  sU     
 
 
!fm\:;;
"1l33:AHH
 
 
rW   )r   r   r   r5   r   )rT   r5   s    @rU   columnszCompositeProperty.columns  s?     ~4A
 
 
 
Z
 
 
 	
rW   Optional[MapperProperty[_CC]]c                    | S rR   r   r   s    rU   mapper_property_to_assignz+CompositeProperty.mapper_property_to_assign  s    rW   $List[Tuple[schema.Column[Any], int]]c                $    d | j         D             S )Nc                $    g | ]}|j         	|dfS )Nr   )table)r   cs     rU   r   z7CompositeProperty.columns_to_assign.<locals>.<listcomp>  s    @@@1ArW   )r   r   s    rU   columns_to_assignz#CompositeProperty.columns_to_assign  s    @@@@@@rW   c                    t           j        j        j        }| j        D ]G}t          ||          s|}| j        |_        | j        r| j        |_        d|_        | j	        |_	        HdS )zwPropagate configuration arguments made on this composite
        to the target columns, for those that apply.

        ))r   T)
instrumentTN)
r   r   r   r4   r  r   r   r   strategy_keyr   )rT   r4   ra   cprops       rU   r   z-CompositeProperty._setup_arguments_on_columns	  sx     6EJ 
	% 
	%DdN33 #'#6E } P!%%O"*EKK
	% 
	%rW   c                    dfd}d fd
}d  fdd! fd}d" fd}t          j         j        d|d           t          j         j        d|d           t          j         j        d|dd           t          j         j        d|dd           t          j         j        d|dd            j        j         j                 }|j        |j        _         j        |j        j        _        dS )#z>Establish events that populate/expire the composite attribute.rL   rM   contextr1   rP   rZ   c                &     | |d d           d S )NF
is_refreshr   )rL   r/  _load_refresh_handlers     rU   load_handlerz=CompositeProperty._setup_event_handlers.<locals>.load_handler   s%     "!%$5IIIIIIrW   to_loadOptional[Sequence[str]]c                    |r3j         h                    j                                      |          r | ||d           d S d S )NTr1  )rb   unionr   intersection)rL   r/  r5  r3  rT   s      rU   refresh_handlerz@CompositeProperty._setup_event_handlers.<locals>.refresh_handler%  sg      P
  !566l7##P &%eWg$OOOOOOP PrW   r2  r^   c                      j         }|r	|j        u rj        |v rd S j        D ]	}||vr d S 
 j         fdj        D              |j        <   d S )Nc                *    g | ]}j         |         S r   )dict)r   rb   rL   s     rU   r   zZCompositeProperty._setup_event_handlers.<locals>._load_refresh_handler.<locals>.<listcomp>O  s    BBBc%*S/BBBrW   )r=  r   rb   r   r   )rL   r/  r5  r2  rN   krT   s   `     rU   r3  zFCompositeProperty._setup_event_handlers.<locals>._load_refresh_handler1  s     JE ")T-A"A"A(e##
 )  E>>FF " 3d2BBBBT-ABBBE$(OOOrW   keysc                    |'t          j                                      |          r"| j                            j        d            d S d S rR   )r   r   r9  r=  r   rb   )rL   r?  rT   s     rU   expire_handlerz?CompositeProperty._setup_event_handlers.<locals>.expire_handlerR  sL     |s4#788EEdKK|
tx..... |rW   rX   rY   
connectionr7   c                H    |j                             j        d           dS )zAfter an insert or update, some columns may be expired due
            to server side defaults, or re-populated due to client side
            defaults.  Pop out the composite value here so that it
            recreates.

            N)r=  r   rb   )rX   rB  rL   rT   s      rU   insert_update_handlerzFCompositeProperty._setup_event_handlers.<locals>.insert_update_handlerX  s#     JNN48T*****rW   after_insertT)rawafter_updateload)rF  	propagater   expireN)rL   rM   r/  r1   rP   rZ   )rL   rM   r/  r1   r5  r6  rP   rZ   )
rL   rM   r/  r1   r5  r6  r2  r^   rP   rZ   )rL   rM   r?  r6  rP   rZ   )rX   rY   rB  r7   rL   rM   rP   rZ   )	r!   listenr   r   rb   r   r   r   r   )rT   r4  r:  rA  rD  r   r3  s   `     @rU   r   z'CompositeProperty._setup_event_handlers  s   	J 	J 	J 	J 	J 	J

	P 
	P 
	P 
	P 
	P 
	P 
	P	 	 	 	 	 	B	/ 	/ 	/ 	/ 	/ 	/	+ 	+ 	+ 	+ 	+ 	+ 	K)>D	
 	
 	
 	
 	K)>D	
 	
 	
 	
 	K44	
 	
 	
 	
 	KO	
 	
 	
 	
 	K>tt	
 	
 	
 	
 [.tx8
#-#6
 373F
 000rW   Sequence[str]c                $    d | j         D             S )Nc                    g | ]	}|j         
S r   re   r   ra   s     rU   r   z5CompositeProperty._attribute_keys.<locals>.<listcomp>~  s    000T000rW   r  r   s    rU   r   z!CompositeProperty._attribute_keys|  s    00TZ0000rW    Callable[[Dict[str, Any]], None]c                d      j         r j         nddd  j        D             d fd
}|S )Nvalr   rP   
Tuple[Any]c                *    |                                  S rR   r   )rR  s    rU   
get_valueszOCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.get_values  s    //111rW   c                    g | ]	}|j         
S r   re   rO  s     rU   r   zOCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.<listcomp>  s    111d111rW   	dest_dictDict[str, Any]rZ   c                    |                      d t           |                     j                                      D                        d S )Nc                    i | ]\  }}||	S r   r   )r   rb   rR  s      rU   
<dictcomp>zaCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.populate.<locals>.<dictcomp>  s.        S   rW   )r   r   r   rb   )rW  r   rU  rT   s    rU   populatezMCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.populate  sh     $'zz)--*A*ABB% %      rW   )rR  r   rP   rS  )rW  rX  rP   rZ   )r   r  )rT   r\  r   rU  s   ` @@rU   )_populate_composite_bulk_save_mappings_fnz;CompositeProperty._populate_composite_bulk_save_mappings_fn  sv     - 	2;JJ2 2 2 2 21dj111	 	 	 	 	 	 	 	 rW   rL   rM   rN   r,   rO   r   r.   c                *   g }g }d}| j         D ]}|j        }|j        |         j                            ||          }	|	                                rd}|	                                }
|
r|                    |
           n|                    d           |	j	        r|                    |	j	                   |                    d           |r(t          j         | j        | gd | j        | g          S t          j        d | j        | gd          S )z>Provided for userland code that uses attributes.get_history().FTNr   )r  rb   r   r   rV   has_changesnon_deletedextendr  deletedr   r.   r   )rT   rL   rN   rO   addedrb  has_historyra   rb   histr`  s              rU   rV   zCompositeProperty.get_history  s?    J 	% 	%D(C=%*66ueDDD!! #"**,,K #[))))T"""| %t|,,,,t$$$$ 	N%%%u-.%%w/0   %b+?4+?+G*H"MMMrW   Composite.Comparator[_CC]c                .    |                      | |          S rR   )r   )rT   rX   s     rU   r   z%CompositeProperty._comparator_factory  s     &&tV444rW   c                  (     e Zd Zd fdZddZ xZS )!CompositeProperty.CompositeBundle	property_Composite[_T]exprr;   c                T    || _          t                      j        |j        g|R   d S rR   )rp   r   rf   rb   )rT   rj  rl  r   s      rU   rf   z*CompositeProperty.CompositeBundle.__init__  s3    
 &DMEGGY]2T222222rW   querySelect[Any]procs#Sequence[Callable[[Row[Any]], Any]]labelsrL  rP   Callable[[Row[Any]], Any]c                     d fd}|S )NrowRow[Any]rP   r   c                <      j         j         fdD              S )Nc                &    g | ]} |          S r   r   )r   procru  s     rU   r   zXCompositeProperty.CompositeBundle.create_row_processor.<locals>.proc.<locals>.<listcomp>  s!    222Ddd3ii222rW   )rp   r   )ru  rp  rT   s   `rU   ry  zDCompositeProperty.CompositeBundle.create_row_processor.<locals>.proc  s/    4t}42222E222 rW   )ru  rv  rP   r   r   )rT   rn  rp  rr  ry  s   ` `  rU   create_row_processorz6CompositeProperty.CompositeBundle.create_row_processor  s.          
 KrW   )rj  rk  rl  r;   )rn  ro  rp  rq  rr  rL  rP   rs  )rj   rk   rl   rf   rz  __classcell__r   s   @rU   CompositeBundleri    sQ        	3 	3 	3 	3 	3 	3	 	 	 	 	 	 	 	rW   r}  c                      e Zd ZU dZdZded<   ej        dd            Zdd	Z	ej        dd
            Z
ddZej        dd            Zd dZd dZd dZd dZd dZd dZd!dZdS )"CompositeProperty.Comparatora  Produce boolean, comparison, and other operators for
        :class:`.Composite` attributes.

        See the example in :ref:`composite_operations` for an overview
        of usage , as well as the documentation for :class:`.PropComparator`.

        .. seealso::

            :class:`.PropComparator`

            :class:`.ColumnOperators`

            :ref:`types_operators`

            :attr:`.TypeEngine.comparator_factory`

        Nz%RODescriptorReference[Composite[_PT]]ra   rP   r;   c                .    t          j        | j        ddiS )Nr   F)r&   r;   r  r   s    rU   clausesz$CompositeProperty.Comparator.clauses  s%    ("7  rW   &CompositeProperty.CompositeBundle[_PT]c                    | j         S rR   r%   r   s    rU   __clause_element__z/CompositeProperty.Comparator.__clause_element__  s
    ?"rW   c                    | j                             | j        | j        | j        j        d          }t
                              | j        |          S )N)parententityparentmapper	proxy_key)r  	_annotate_parententityra   rb   r   r}  )rT   r  s     rU   r&   z'CompositeProperty.Comparator.expression  sP    l,,$($6$($6!%  G %44TYHHHrW   rt   r   (Sequence[Tuple[_DMLColumnArgument, Any]]c                   t          |t                    r|j        }|d | j        j        D             }nst          | j        j        t                    r5t          || j        j                  r| j                            |          }nt          j	        d| j        d|          t          t          | j        |                    S )Nc                    g | ]}d S rR   r   )r   rb   s     rU   r   zDCompositeProperty.Comparator._bulk_update_tuples.<locals>.<listcomp>  s    DDD3$DDDrW   z!Can't UPDATE composite attribute z to )r   r(   rt   ra   r   r   r  r   r   r   listr   r  )rT   rt   r   s      rU   _bulk_update_tuplesz0CompositeProperty.Comparator._bulk_update_tuples  s     %// $ }DD$)*CDDDDI5t<< 
ty0B B 
 BB  **yyy%%)  
 D5v>>???rW   r  c                Z      j         r fd j        j        D             S  j        j        S )Nc                N    g | ]!}t          j        j        |j                  "S r   )r~   _adapt_to_entityentityrb   r  s     rU   r   zECompositeProperty.Comparator._comparable_elements.<locals>.<listcomp>  s;        D18$(CC  rW   )r  ra   r  r   s   `rU   r  z1CompositeProperty.Comparator._comparable_elements  sK    $ 6    $	 >   
 y55rW   otherColumnElement[bool]c                B    |                      t          j        |          S rR   )_comparer'   eqrT   r  s     rU   __eq__z#CompositeProperty.Comparator.__eq__&      ==u555rW   c                B    |                      t          j        |          S rR   )r  r'   ner  s     rU   __ne__z#CompositeProperty.Comparator.__ne__)  r  rW   c                B    |                      t          j        |          S rR   )r  r'   ltr  s     rU   __lt__z#CompositeProperty.Comparator.__lt__,  r  rW   c                B    |                      t          j        |          S rR   )r  r'   gtr  s     rU   __gt__z#CompositeProperty.Comparator.__gt__/  r  rW   c                B    |                      t          j        |          S rR   )r  r'   ler  s     rU   __le__z#CompositeProperty.Comparator.__le__2  r  rW   c                B    |                      t          j        |          S rR   )r  r'   ger  s     rU   __ge__z#CompositeProperty.Comparator.__ge__5  r  rW   r   r=   c                    |d gt           j        j                  z  }n j                            |          }fdt	           j        j        |          D             } j        r j        J  fd|D             }t          j        | S )Nc                .    g | ]\  }} ||          S r   r   )r   r  br   s      rU   r   z9CompositeProperty.Comparator._compare.<locals>.<listcomp>G  s7       Aq A  rW   c                :    g | ]}                     |          S r   )adapter)r   xrT   s     rU   r   z9CompositeProperty.Comparator._compare.<locals>.<listcomp>M  s#    DDD1t||ADDDrW   )	r  ra   r  r   r   r  r  r$   and_)rT   r   r  r   comparisonss   ``   rU   r  z%CompositeProperty.Comparator._compare?  s     }#di&D"E"EEBB5II   	 >GG  K $ E|///DDDDDDD8[))rW   )rP   r;   )rP   r  )rt   r   rP   r  rP   r  )r  r   rP   r  )r   r=   r  r   rP   r  )rj   rk   rl   r   __hash__r   r   memoized_propertyr  r  r&   r  r  r  r  r  r  r  r  r  r   rW   rU   r   r    sY        	 	& 3333			 	 	 
 		
	# 	# 	# 	# 
		I 	I 	I 
 		I	@ 	@ 	@ 	@0 
		6 	6 	6 
 		6	6 	6 	6 	6	6 	6 	6 	6	6 	6 	6 	6	6 	6 	6 	6	6 	6 	6 	6	6 	6 	6 	6	* 	* 	* 	* 	* 	*rW   r   c                T    t          | j        j        j                  dz   | j        z   S )N.)rc   r   r   rj   rb   r   s    rU   __str__zCompositeProperty.__str__P  s$    4;%.//#5@@rW   rR   )r   r   r   r   r   r   r   r^   r   r^   r   rI   r   r   r   r   r   r   r   )rt   r   rP   r   rP   rZ   )r   r2   r   r-   r   r   r   rI   rb   rc   r   r   r   r   r   r   r   r^   rP   rZ   )
r   r-   r   r   r   rI   rb   rc   rP   rZ   r  )rP   r  )rP   r  )rP   r!  )rP   r$  )rP   rL  )rP   rP  ri   )rX   rY   rP   rf  )rP   rc   )*rj   rk   rl   r   r   rf   r   r   r   objectr   r   r   preload_moduler   r   r   r  r  r  non_memoized_propertyr   rp   r#  r)  r   r   r   r]  r   rq   rV   r   orm_utilBundlerD   r}  r   rF   r   r  r{  r|  s   @rU   r   r      s        
 
 :999....    .--- 	& :>$#>B$(& & & & & & & &P% % % % % %" " " "+ + + + fhhOH5 H5 H5 H5T T4557 7 7 657r   6 T455T344%A %A %A 54 65%AN 
N N N N 
T)**   +* 2 
T)**
 
 
 +*  
    X A A A XA T)**% % % +*%&[G [G [G [G~ 
1 1 1 1   8  +6	#N #N #N #N #NJ5 5 5 5
    (/"-   ,v* v* v* v* v*^C( v* v* v*pA A A A A A A ArW   r   c                      e Zd ZdZdZdS )	CompositeaS  Declarative-compatible front-end for the :class:`.CompositeProperty`
    class.

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

    .. versionchanged:: 2.0 Added :class:`_orm.Composite` as a Declarative
       compatible subclass of :class:`_orm.CompositeProperty`.

    .. seealso::

        :ref:`mapper_composite`

    TNrj   rk   rl   r   inherit_cacher   rW   rU   r  r  T  s!          MrW   r  c                  ,     e Zd ZdZd	dZd
 fdZ xZS )ConcreteInheritedPropertya4  A 'do nothing' :class:`.MapperProperty` that disables
    an attribute on a concrete subclass that is only present
    on the inherited mapper, not the concrete classes' mapper.

    Cases where this occurs include:

    * When the superclass mapper is mapped against a
      "polymorphic union", which includes all attributes from
      all subclasses.
    * When a relationship() is configured on an inherited mapper,
      but not on the subclass mapper.  Concrete mappers require
      that relationship() is configured explicitly on each
      subclass.

    rX   rY   rP   Type[PropComparator[_T]]c                    d }| j                                         D ].}|j        | j                 }t	          |dd           	|j        } n/|J  |||          S )Nr   )r   iterate_to_root_propsrb   r~   r   )rT   rX   comparator_callablemr   s        rU   r   z-ConcreteInheritedProperty._comparator_factoryx  s}     #,,.. 	 	A"Aq.55A&'&:# B #...""1f---rW   rZ   c                     t                                                       d fd G  fdd          } |             _        d S )NrP   r	   c            	     T    t          d j        d j        d j        d          )Nz	Concrete z does not implement attribute z9 at the instance level.  Add this property explicitly to r  )r   r   rb   r   s   rU   warnz0ConcreteInheritedProperty.__init__.<locals>.warn  s7     . ;;;$+++7  rW   c                  6    e Zd ZdfdZdfdZd fd
ZdS )DConcreteInheritedProperty.__init__.<locals>.NoninheritedConcretePropsr   rs   rt   rP   r	   c                                  d S rR   r   )r  rs   rt   r  s      rU   __set__zLConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__set__      rW   c                                  d S rR   r   )r  rs   r  s     rU   
__delete__zOConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__delete__  r  rW   ownerc                .    |j         S               d S rR   )rK   )r  rs   r  rT   r  s      rU   __get__zLConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__get__  s    ;?*rW   N)r  r   rs   r   rt   r   rP   r	   )r  r   rs   r   rP   r	   )r  r   rs   r   r  r   rP   r   )rj   rk   rl   r  r  r  )rT   r  s   rU   NoninheritedConcretePropr    st                          rW   r  )rP   r	   )r   rf   rK   )rT   r  r  r   s   ` @rU   rf   z"ConcreteInheritedProperty.__init__  s    	 	 	 	 	 	
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 3244rW   )rX   rY   rP   r  r  )rj   rk   rl   r   r   rf   r{  r|  s   @rU   r  r  g  s[          . . . .5 5 5 5 5 5 5 5 5 5rW   r  c                       e Zd ZU dZded<   	 	 	 	 	 	 d(d) fdZesed*d            Ze	j
        d+d            Zd,dZej        fd-d"Z e	j        d#          d.d'            Z xZS )/SynonymPropertya8  Denote an attribute name as a synonym to a mapped property,
    in that the attribute will mirror the value and expression behavior
    of another attribute.

    :class:`.Synonym` is constructed using the :func:`_orm.synonym`
    function.

    .. seealso::

        :ref:`synonyms` - Overview of synonyms

    "Optional[Type[PropComparator[_T]]]r   Nrw   rc   
map_columnOptional[bool]rK   Optional[Any]r   r   r   r   rJ   rI   c                2   t                                          |           || _        || _        || _        || _        |r|| _        n|r|j        r|j        | _        nd | _        |r| j        	                    |           t          j        |            d S r   )r   rf   rw   r  rK   r   rJ   r   r   r   r   r   )	rT   rw   r  rK   r   r   r   rJ   r   s	           rU   rf   zSynonymProperty.__init__  s     	+<===	$$"4 	DHH 	J. 	!)DHHDH 	#IT"""%%%%%rW   rP   r^   c                T    t          | j        j        | j                  j        j        S rR   )r~   r   r   rw   r   r`   r   s    rU   r`   zSynonymProperty.uses_objects  s    4;-ty99>KKrW   /Union[MapperProperty[_T], SQLORMOperations[_T]]c                t   t          | j        j        | j                  }t	          |d          rt          |j        t                    sit          |t          j	                  r|j
        S t          |t                    r|S t          j        d| j        j        j        d| j        d|          |j        S )Nrp   zsynonym() attribute "r  z+" only supports ORM mapped attributes, got )r~   r   r   rw   r   r   rp   r   r   r0   
comparatorr   r   r   rj   )rT   r   s     rU   _proxied_objectzSynonymProperty._proxied_object  s     t{)4955tZ(( 	
M>1
 1
 	
 $
 =>> &D"233 ,, ;%...			44A  
 }rW   rX   rY   SQLORMOperations[_T]c                    | j         }t          |t                    r6| j        r|                     ||          }n|                    ||          }|S |S rR   )r  r   r   r   )rT   rX   ra   comps       rU   r   z#SynonymProperty._comparator_factory  s]    #dN++ 	& =..tV<<..tV<<KKrW   rL   rM   rN   r,   rO   r   r.   c                z    t          | j        j        | j                  }|j                            |||          S )N)rO   )r~   r   r   rw   r   rV   )rT   rL   rN   rO   r   s        rU   rV   zSynonymProperty.get_history  s7     )00BDI(N(Ny$$UE7$CCCrW   r   r   initrZ   c           
     |   t           j        j        }| j        r| j        |j        j        vr2t          j        d| j	        d|j        j
        d| j        d          |j        j        | j                 |j        v rd|j        |j        j        | j                          j        | j	        k    r4t          j        d| j        d| j	        d| j	        d| j                  |                    |j        j        | j                           }|                    | j	        ||d	
           | j        |_        || _        d S )NzCan't compile synonym 'z': no column on table 'z	' named ''z'Can't call map_column=True for synonym =z4, a ColumnProperty already exists keyed to the name z for column T)r  	setparent)r   r   r   r  rb   persist_selectabler(  r   r   rw   descriptionr  r4   _configure_property_mapped_by_synonymr   )rT   r   r  
propertiesr   s        rU   
set_parentzSynonymProperty.set_parent  sV   ^2
? 	,xv8:::** 			1===   )+DH5+, ,,-/99 
 ** xxxDIIItxxA   &0%>%>)+DH5& &A &&ty!$$&OOO#'8A rW   )NNNNNN)rw   rc   r  r  rK   r  r   r  r   r   r   r   rJ   rI   rh   )rP   r  )rX   rY   rP   r  ri   )r   rY   r  r^   rP   rZ   )rj   rk   rl   r   r   rf   r   rp   r`   r   r  r  r   r   rq   rV   r  r  r{  r|  s   @rU   r  r    s*          ;:::
 &*$(AE9=$(!& & & & & & &6  L		L 	L 	L 
	L 
   ,
 
 
 
   +6	D D D D D T455# # # 65# # # # #rW   r  c                      e Zd ZdZdZdS )SynonymaK  Declarative front-end for the :class:`.SynonymProperty` class.

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

    .. versionchanged:: 2.0 Added :class:`_orm.Synonym` as a Declarative
       compatible subclass for :class:`_orm.SynonymProperty`

    .. seealso::

        :ref:`synonyms` - Overview of synonyms

    TNr  r   rW   rU   r  r  &  s!          MrW   r  )gr   
__future__r   dataclassesr   r   r  r   typingr   r   r   r   r	   r
   r   r   r   r   r   r   weakref r   r   r  baser   r   r   r   r   
interfacesr   r   r   r   r   r   r   r!   r"   r   r#   r$   r&   r'   sql.elementsr(   util.typingr)   r*   r+   _typingr,   r-   r.   r/   r0   r/  r1   r  r2   rX   r3   r  r4   r5   rL   r6   engine.baser7   
engine.rowr8   sql._typingr9   r:   r;   r<   sql.operatorsr=   
sql.schemar>   sql.selectabler?   r@   rA   rB   rC   rD   rF   rH   rc   _CompositeAttrTyper   WeakKeyDictionaryr   r   r   r  r  r  r  r   rW   rU   <module>r	     s    
 # " " " " " $ $ $ $ $ $                                                                                                   $ $ $ $ $ $ & & & & & &             " " " " " " ) ) ) ) ) ) / / / / / / $ $ $ $ $ $ & & & & & & & & & & & &       ) ) ) ) ) )                                           ( ( ( ( ( ( " " " " " " $ $ $ $ $ $ # # # # # # 
 4&&&&&&&&&&&&######111111......((((((111111******(((((($$$$$$((((((      000000'''''')))))),,,,,,,,,,,,######''''''111111//////111111333333WTge3EH EH EH EH EH+ EH EH EHP 	  ge3
 G         
]
A ]
A ]
A ]
A ]
A.0B30G]
A ]
A ]
A@    !"%'9"'=   &55 55 55 55 55 22 6 55 55 55pD D D D D(, D D DN    ob!#5b#9     rW   