
    	h                       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                  Z    e Zd ZU dZdZded<   dZdZded<   dd
Z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return!Sequence[QueryableAttribute[Any]]c                     t          d          )Nz?This MapperProperty does not implement column loader strategiesNotImplementedErrorselfs    l/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/sqlalchemy/orm/descriptor_props.py_column_strategy_attrsz)DescriptorProperty._column_strategy_attrsf   s    !M
 
 	
    stateInstanceState[Any]dict_r,   passiver   r.   c                    t                      NrO   )rR   rV   rX   rY   s       rS   get_historyzDescriptorProperty.get_historyk   s     "###rU   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>._ProxyImplFTrL   boolc                    j         S r[   )uses_objects)rR   props    rS   re   zDDescriptorProperty.instrument_class.<locals>._ProxyImpl.uses_objects{   s    ((rU   keystrc                    || _         d S r[   rg   )rR   rg   s     rS   __init__z@DescriptorProperty.instrument_class.<locals>._ProxyImpl.__init__   s    rU   rV   rW   rX   r,   rY   r   r.   c                2                         |||          S r[   )r\   )rR   rV   rX   rY   rf   s       rS   r\   zCDescriptorProperty.instrument_class.<locals>._ProxyImpl.get_history   s     ''ug>>>rU   NrL   rc   )rg   rh   rV   rW   rX   r,   rY   r   rL   r.   )__name__
__module____qualname__accepts_scalar_loaderload_on_unexpire
collectionpropertyre   rk   r   PASSIVE_OFFr\   )rf   s   rS   
_ProxyImplrb   v   s        $)!#J) ) ) ) ) X)    (3'>	? ? ? ? ? ? ? ? ?rU   rw   objr   valuerL   r_   c                4    t          | j        |           d S r[   )setattrname)rx   ry   rR   s     rS   fsetz1DescriptorProperty.instrument_class.<locals>.fset   s    TY.....rU   c                2    t          | j                   d S r[   )delattrr|   rx   rR   s    rS   fdelz1DescriptorProperty.instrument_class.<locals>.fdel   s    TY'''''rU   c                .    t          | j                  S r[   )getattrr|   r   s    rS   fgetz1DescriptorProperty.instrument_class.<locals>.fget   s    sDI...rU   )r   r}   r   c                 .                                    S r[   )_comparator_factory)r]   rR   s   rS   <lambda>z5DescriptorProperty.instrument_class.<locals>.<lambda>   s    D,,V44 rU   )rJ   original_property)rx   r   ry   r   rL   r_   )rx   r   rL   r_   )rx   r   rL   r   )r   AttributeImplrK   r   class_rg   _is_userland_descriptorru   create_proxied_attributeparentrJ   implclass_managerinstrument_attribute)	rR   r]   rw   descr}   r   r   
proxy_attrrf   s	   ``      @rS   instrument_classz#DescriptorProperty.instrument_classs   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GrU   rL   rM   rn   r]   r^   rL   r_   )ro   rp   rq   __doc__rJ   __annotations__re   _links_to_entityrT   r   rv   r\   r    rU   rS   rH   rH   [   s             CL((((
 
 
 
  +6	$ $ $ $ $2H 2H 2H 2H 2H 2HrU   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dad&Z e	            Z
dad'Z ej        d(          dbd8            Zdad9Z ej        d(           ej        d:          dcd;                        Zej        ddd=            Zej         ej        d>          ded@                        ZdddAZej         ej        d>          dfdC                        ZedgdE            ZedhdG            Z ej        d>          dadH            ZdadIZej        didK            ZdjdMZej        fdkdUZ dldWZ! G dX dYe"j#        e$                   Z% G dZ d[e&e'                   Z(dmd\Z) xZ*S )n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   rc   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   )superrk   
isinstancer   rh   r$   r<   r   r   r   r   r   	__class__
Comparatorr   r   r   updater   set_creation_order_create_descriptor_init_accessor)rR   r   r   r   r   r   r   r   r   r   r   s             rS   rk   zCompositeProperty.__init__   s     	+<===nvsC4E&FGG 	(*U2DJ#'D  #1D DJ, 
 "- * 	
 .2*IT"""%%%!!!rU   r]   r^   rL   r_   c                r    t                                          |           |                                  d S r[   )r   r   _setup_event_handlers)rR   r]   r   s     rS   r   z"CompositeProperty.instrument_class   s3      (((""$$$$$rU   ry   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   ro   )rR   ry   accessoraes       rS   _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_columnsrQ   s    rS   do_initzCompositeProperty.do_init  s    
 	((*****rU   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   rL   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   ).0rg   r   s     rS   
<listcomp>zFCompositeProperty._create_descriptor.<locals>.fget.<locals>.<listcomp>#  s0       /2GHc**  rU   )r   instance_dictinstance_staterg   _attribute_keysr   
issupersetr   managerdispatchrefresh_COMPOSITE_FGETget)r   rX   rV   valuesrR   s   `   rS   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,,,rU   ry   r_   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 r[   )r   r   r   r   rg   r   _active_historyr   r   NO_VALUEsetr   r   r{   zipr   )
r   ry   rX   rV   attrpreviousfnrg   r   rR   s
           rS   r}   z2CompositeProperty._create_descriptor.<locals>.fset6  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 2rU   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 r[   )r   r   r   r   rg   r   r   popr   r   remover   r   r{   )r   rV   rX   r   r   rg   r   rR   s         rS   r   z2CompositeProperty._create_descriptor.<locals>.fdelM  s    -h77E,X66E=*D}, N4>>		$(D)))) 99TX/C/LMM=*DM  $)<<<+ - -#t,,,,- -rU   N)r   r   rL   r   )r   r   ry   r   rL   r_   )r   r   rL   r_   )ru   rK   )rR   r}   r   r   s   `  @rS   r   z$CompositeProperty._create_descriptor  s    	- 	- 	- 	- 	- 	-6	2 	2 	2 	2 	2 	2 	2.	- 	- 	- 	- 	- 	- 	-  #4t44rU   sqlalchemy.orm.properties	decl_scanr2   registryr-   cls	Type[Any]originating_modulerg   rh   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   rh   r*   hasattrr   r   ArgumentErrorr   r   _setup_for_dataclassr   r#   r>   r|   r   )rR   r   r   r   r   rg   r   r   r   r   r5   argumentstr_argr   s                 rS   declarative_scanz"CompositeProperty.declarative_scan_  s    ~4A (+3$$S#....X 	-))!,H 	,,4(C(( J- - -  &- #8->??+00 ]] 
 !.P P PELP P P   3#5t   $,D ,-- 	%%8S*<c    
  tlFM%BCC	) .5   	rU   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   )r|   )r   ps     rS   r   z4CompositeProperty._init_accessor.<locals>.<listcomp>  s    ;;;Q!&;;;rU   r   c                     |           fS r[   r   )rx   getters    rS   r   z2CompositeProperty._init_accessor.<locals>.<lambda>  s    &&++ rU   c                *    |                                  S r[   r   )rx   s    rS   r   z2CompositeProperty._init_accessor.<locals>.<lambda>  s     8 8 : : rU   )r   r   r   inspect	signatureoperator
attrgetter
parametersr   lenr   r   typer   )rR   inspr   s     @rS   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 -,,,>> rU   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  ro   r   declarative_scan_for_compositer|   r   r#   r>   _undefer_column_name)rR   r   r   r   r   rg   r5   	decl_baser	  paramr   s              rS   r   z&CompositeProperty._setup_for_dataclass  sz    ~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@@@5	A 	ArU   rM   c                *      fd j         D             S )Nc                N    g | ]!}t          j        j        |j                  "S r   )r   r   r   rg   r   rf   rR   s     rS   r   z:CompositeProperty._comparable_elements.<locals>.<listcomp>  s*    MMM$*DH55MMMrU   propsrQ   s   `rS   _comparable_elementsz&CompositeProperty._comparable_elements  s    MMMM$*MMMMrU   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   rh   r   get_propertyr#   r>   _columntopropertycolumnr   r/   ru   r   r   r   append)rR   r  r5   r   rf   s        rS   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rU   c                    | j         S r[   )r  rQ   s    rS   rT   z(CompositeProperty._column_strategy_attrs   s    ((rU   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     rS   r   z-CompositeProperty.columns.<locals>.<listcomp>  sU     
 
 
!fm\:;;
"1l33:AHH
 
 
rU   )r   r   r   r5   r   )rR   r5   s    @rS   columnszCompositeProperty.columns  s?     ~4A
 
 
 
Z
 
 
 	
rU   Optional[MapperProperty[_CC]]c                    | S r[   r   rQ   s    rS   mapper_property_to_assignz+CompositeProperty.mapper_property_to_assign  s    rU   $List[Tuple[schema.Column[Any], int]]c                $    d | j         D             S )Nc                $    g | ]}|j         	|dfS )Nr   )table)r   cs     rS   r   z7CompositeProperty.columns_to_assign.<locals>.<listcomp>  s    @@@1ArU   )r%  rQ   s    rS   columns_to_assignz#CompositeProperty.columns_to_assign  s    @@@@@@rU   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   )rR   r4   rf   cprops       rS   r   z-CompositeProperty._setup_arguments_on_columns  sx     6EJ 
	% 
	%DdN33 #'#6E } P!%%O"*EKK
	% 
	%rU   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.rV   rW   contextr1   rL   r_   c                &     | |d d           d S )NF
is_refreshr   )rV   r4  _load_refresh_handlers     rS   load_handlerz=CompositeProperty._setup_event_handlers.<locals>.load_handler,  s%     "!%$5IIIIIIrU   to_loadOptional[Sequence[str]]c                    |r3j         h                    j                                      |          r | ||d           d S d S )NTr6  )rg   unionr   intersection)rV   r4  r:  r8  rR   s      rS   refresh_handlerz@CompositeProperty._setup_event_handlers.<locals>.refresh_handler1  sg      P
  !566l7##P &%eWg$OOOOOOP PrU   r7  rc   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   rg   rV   s     rS   r   zZCompositeProperty._setup_event_handlers.<locals>._load_refresh_handler.<locals>.<listcomp>[  s    BBBc%*S/BBBrU   )rB  r   rg   r   r   )rV   r4  r:  r7  rX   krR   s   `     rS   r8  zFCompositeProperty._setup_event_handlers.<locals>._load_refresh_handler=  s     JE ")T-A"A"A(e##
 )  E>>FF " 3d2BBBBT-ABBBE$(OOOrU   keysc                    |'t          j                                      |          r"| j                            j        d            d S d S r[   )r   r   r>  rB  r   rg   )rV   rD  rR   s     rS   expire_handlerz?CompositeProperty._setup_event_handlers.<locals>.expire_handler^  sL     |s4#788EEdKK|
tx..... |rU   r]   r^   
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)rB  r   rg   )r]   rG  rV   rR   s      rS   insert_update_handlerzFCompositeProperty._setup_event_handlers.<locals>.insert_update_handlerd  s#     JNN48T*****rU   after_insertT)rawafter_updateload)rK  	propagater   expireN)rV   rW   r4  r1   rL   r_   )rV   rW   r4  r1   r:  r;  rL   r_   )
rV   rW   r4  r1   r:  r;  r7  rc   rL   r_   )rV   rW   rD  r;  rL   r_   )r]   r^   rG  r7   rV   rW   rL   r_   )	r!   listenr   r   rg   r   r   r   r   )rR   r9  r?  rF  rI  r   r8  s   `     @rS   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0rU   Sequence[str]c                $    d | j         D             S )Nc                    g | ]	}|j         
S r   rj   r   rf   s     rS   r   z5CompositeProperty._attribute_keys.<locals>.<listcomp>  s    000T000rU   r  rQ   s    rS   r   z!CompositeProperty._attribute_keys  s    00TZ0000rU    Callable[[Dict[str, Any]], None]c                d      j         r j         nddd  j        D             d fd
}|S )Nvalr   rL   
Tuple[Any]c                *    |                                  S r[   r  )rW  s    rS   
get_valueszOCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.get_values  s    //111rU   c                    g | ]	}|j         
S r   rj   rT  s     rS   r   zOCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.<listcomp>  s    111d111rU   	dest_dictDict[str, Any]r_   c                    |                      d t           |                     j                                      D                        d S )Nc                    i | ]\  }}||	S r   r   )r   rg   rW  s      rS   
<dictcomp>zaCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.populate.<locals>.<dictcomp>  s.        S   rU   )r   r   r   rg   )r\  r   rZ  rR   s    rS   populatezMCompositeProperty._populate_composite_bulk_save_mappings_fn.<locals>.populate  sh     $'zz)--*A*ABB% %      rU   )rW  r   rL   rX  )r\  r]  rL   r_   )r   r  )rR   ra  r   rZ  s   ` @@rS   )_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	 	 	 	 	 	 	 	 rU   rV   rW   rX   r,   rY   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  rg   r   r   r\   has_changesnon_deletedextendr  deletedr   r.   r   )rR   rV   rX   rY   addedrg  has_historyrf   rg   histre  s              rS   r\   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MrU   Composite.Comparator[_CC]c                .    |                      | |          S r[   )r   )rR   r]   s     rS   r   z%CompositeProperty._comparator_factory  s     &&tV444rU   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 r[   )ru   r   rk   rg   )rR   ro  rq  r   s      rS   rk   z*CompositeProperty.CompositeBundle.__init__  s3    
 &DMEGGY]2T222222rU   querySelect[Any]procs#Sequence[Callable[[Row[Any]], Any]]labelsrQ  rL   Callable[[Row[Any]], Any]c                     d fd}|S )NrowRow[Any]rL   r   c                <      j         j         fdD              S )Nc                &    g | ]} |          S r   r   )r   procrz  s     rS   r   zXCompositeProperty.CompositeBundle.create_row_processor.<locals>.proc.<locals>.<listcomp>  s!    222Ddd3ii222rU   )ru   r   )rz  ru  rR   s   `rS   r~  zDCompositeProperty.CompositeBundle.create_row_processor.<locals>.proc  s/    4t}42222E222 rU   )rz  r{  rL   r   r   )rR   rs  ru  rw  r~  s   ` `  rS   create_row_processorz6CompositeProperty.CompositeBundle.create_row_processor  s.          
 KrU   )ro  rp  rq  r;   )rs  rt  ru  rv  rw  rQ  rL   rx  )ro   rp   rq   rk   r  __classcell__r   s   @rS   CompositeBundlern    sQ        	3 	3 	3 	3 	3 	3	 	 	 	 	 	 	 	rU   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]]rf   rL   r;   c                .    t          j        | j        ddiS )Nr   F)r&   r;   r  rQ   s    rS   clausesz$CompositeProperty.Comparator.clauses  s%    ("7  rU   &CompositeProperty.CompositeBundle[_PT]c                    | j         S r[   r%   rQ   s    rS   __clause_element__z/CompositeProperty.Comparator.__clause_element__  s
    ?"rU   c                    | j                             | j        | j        | j        j        d          }t
                              | j        |          S )N)parententityparentmapper	proxy_key)r  	_annotate_parententityrf   rg   r   r  )rR   r  s     rS   r&   z'CompositeProperty.Comparator.expression  sP    l,,$($6$($6!%  G %44TYHHHrU   ry   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 r[   r   )r   rg   s     rS   r   zDCompositeProperty.Comparator._bulk_update_tuples.<locals>.<listcomp>  s    DDD3$DDDrU   z!Can't UPDATE composite attribute z to )r   r(   ry   rf   r   r   r  r   r   r   listr   r  )rR   ry   r   s      rS   _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>>???rU   rM   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entityrg   r  s     rS   r   zECompositeProperty.Comparator._comparable_elements.<locals>.<listcomp>+  s;        D18$(CC  rU   )r  rf   r  rQ   s   `rS   r  z1CompositeProperty.Comparator._comparable_elements(  sK    $ 6    $	 >   
 y55rU   otherColumnElement[bool]c                B    |                      t          j        |          S r[   )_comparer'   eqrR   r  s     rS   __eq__z#CompositeProperty.Comparator.__eq__2      ==u555rU   c                B    |                      t          j        |          S r[   )r  r'   ner  s     rS   __ne__z#CompositeProperty.Comparator.__ne__5  r  rU   c                B    |                      t          j        |          S r[   )r  r'   ltr  s     rS   __lt__z#CompositeProperty.Comparator.__lt__8  r  rU   c                B    |                      t          j        |          S r[   )r  r'   gtr  s     rS   __gt__z#CompositeProperty.Comparator.__gt__;  r  rU   c                B    |                      t          j        |          S r[   )r  r'   ler  s     rS   __le__z#CompositeProperty.Comparator.__le__>  r  rU   c                B    |                      t          j        |          S r[   )r  r'   ger  s     rS   __ge__z#CompositeProperty.Comparator.__ge__A  r  rU   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      rS   r   z9CompositeProperty.Comparator._compare.<locals>.<listcomp>S  s7       Aq A  rU   c                :    g | ]}                     |          S r   )adapter)r   xrR   s     rS   r   z9CompositeProperty.Comparator._compare.<locals>.<listcomp>Y  s#    DDD1t||ADDDrU   )	r  rf   r  r   r   r  r  r$   and_)rR   r  r  r   comparisonss   ``   rS   r  z%CompositeProperty.Comparator._compareK  s     }#di&D"E"EEBB5II   	 >GG  K $ E|///DDDDDDD8[))rU   )rL   r;   )rL   r  )ry   r   rL   r  r   )r  r   rL   r  )r  r=   r  r   rL   r  )ro   rp   rq   r   __hash__r   r   memoized_propertyr  r  r&   r  r  r  r  r  r  r  r  r  r   rU   rS   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	* 	* 	* 	* 	* 	*rU   r   c                T    t          | j        j        j                  dz   | j        z   S )N.)rh   r   r   ro   rg   rQ   s    rS   __str__zCompositeProperty.__str__\  s$    4;%.//#5@@rU   r[   )r   r   r   r   r   r   r   rc   r   rc   r   rI   r   r   r   r   r   r   r   )ry   r   rL   r   rL   r_   )r   r2   r   r-   r   r   r   rI   rg   rh   r   r   r   r   r   r   r   rc   rL   r_   )r   r2   r   r-   r   r   r   rI   rg   rh   rL   r_   r   )rL   r  )rL   r!  )rL   r&  )rL   r)  )rL   rQ  )rL   rU  rn   )r]   r^   rL   rk  )rL   rh   )+ro   rp   rq   r   r   rk   r   r   r   objectr   r   r   preload_moduler   r   r   r  r  r  rT   non_memoized_propertyr%  ru   r(  r.  r   r   r   rb  r   rv   r\   r   orm_utilBundlerD   r  r   rF   r   r  r  r  s   @rS   r   r      s        
 
 :999....    .--- 	& :>$#>B$(& & & & & & & &P% % % % % %" " " "+ + + + fhhOH5 H5 H5 H5T T4559 9 9 659v   6 T455T344'A 'A 'A 54 65'AR 
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rU   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ro   rp   rq   r   inherit_cacher   rU   rS   r  r  `  s!          MrU   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.

    r]   r^   rL   Type[PropComparator[_T]]c                    d }| j                                         D ].}|j        | j                 }t	          |dd           	|j        } n/|J  |||          S )Nr   )r   iterate_to_root_propsrg   r   r   )rR   r]   comparator_callablemr   s        rS   r   z-ConcreteInheritedProperty._comparator_factory  s}     #,,.. 	 	A"Aq.55A&'&:# B #...""1f---rU   r_   c                     t                                                       d fd G  fdd          } |             _        d S )NrL   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   rg   rQ   s   rS   warnz0ConcreteInheritedProperty.__init__.<locals>.warn  s7     . ;;;$+++7  rU   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   rx   ry   rL   r	   c                                  d S r[   r   )r  rx   ry   r  s      rS   __set__zLConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__set__      rU   c                                  d S r[   r   )r  rx   r  s     rS   
__delete__zOConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__delete__  r  rU   ownerc                .    |j         S               d S r[   )rK   )r  rx   r  rR   r  s      rS   __get__zLConcreteInheritedProperty.__init__.<locals>.NoninheritedConcreteProp.__get__  s    ;?*rU   N)r  r   rx   r   ry   r   rL   r	   )r  r   rx   r   rL   r	   )r  r   rx   r   r  r   rL   r   )ro   rp   rq   r  r  r  )rR   r  s   rS   NoninheritedConcretePropr    st                          rU   r  )rL   r	   )r   rk   rK   )rR   r  r  r   s   ` @rS   rk   z"ConcreteInheritedProperty.__init__  s    	 	 	 	 	 	
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 3244rU   )r]   r^   rL   r  r  )ro   rp   rq   r   r   rk   r  r  s   @rS   r  r  s  s[          . . . .5 5 5 5 5 5 5 5 5 5rU   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d/dZej        fd0d$Z e	j        d%          d1d)            Z xZS )2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   Nr|   rh   
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   rk   r|   r  rK   r   rJ   r   r   r   r   r   )	rR   r|   r  rK   r   r   r   rJ   r   s	           rS   rk   zSynonymProperty.__init__  s     	+<===	$$"4 	DHH 	J. 	!)DHHDH 	#IT"""%%%%%rU   rL   rc   c                T    t          | j        j        | j                  j        j        S r[   )r   r   r   r|   r   re   rQ   s    rS   re   zSynonymProperty.uses_objects  s    4;-ty99>KKrU   /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 )Nru   zsynonym() attribute "r  z+" only supports ORM mapped attributes, got )r   r   r   r|   r   r   ru   r   r   r0   
comparatorr   r   r   ro   )rR   r   s     rS   _proxied_objectzSynonymProperty._proxied_object  s     t{)4955tZ(( 	
M>1
 1
 	
 $
 =>> &D"233 ,, ;%...			44A  
 }rU   rM   c                B    t          | j        j        | j                  fS r[   )r   r   r   r|   rQ   s    rS   rT   z&SynonymProperty._column_strategy_attrs  s    *DI6688rU   r]   r^   SQLORMOperations[_T]c                    | j         }t          |t                    r6| j        r|                     ||          }n|                    ||          }|S |S r[   )r  r   r   r   )rR   r]   rf   comps       rS   r   z#SynonymProperty._comparator_factory  s]    #dN++ 	& =..tV<<..tV<<KKrU   rV   rW   rX   r,   rY   r   r.   c                z    t          | j        j        | j                  }|j                            |||          S )N)rY   )r   r   r   r|   r   r\   )rR   rV   rX   rY   r   s        rS   r\   zSynonymProperty.get_history  s7     )00BDI(N(Ny$$UE7$CCCrU   r   r   initr_   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  rg   persist_selectabler-  r   r   r|   descriptionr  r4   _configure_property_mapped_by_synonymr   )rR   r   r  
propertiesr   s        rS   
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 rU   )NNNNNN)r|   rh   r  r  rK   r  r   r  r   r   r   r   rJ   rI   rm   )rL   r  r   )r]   r^   rL   r  rn   )r   r^   r  rc   rL   r_   )ro   rp   rq   r   r   rk   r   ru   re   r   r  r  rT   r   r   rv   r\   r  r  r  r  s   @rS   r  r    s>          ;:::
 &*$(AE9=$(!& & & & & & &6  L		L 	L 	L 
	L 
   ,9 9 9 9
 
 
 
   +6	D D D D D T455# # # 65# # # # #rU   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   rU   rS   r  r  5  s!          MrU   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   r4  r1   r  r2   r]   r3   r  r4   r5   rV   r6   engine.baser7   
engine.rowr8   sql._typingr9   r:   r;   r<   sql.operatorsr=   
sql.schemar>   sql.selectabler?   r@   rA   rB   rC   rD   rF   rH   rh   _CompositeAttrTyper   WeakKeyDictionaryr   r   r   r  r  r  r  r   rU   rS   <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JH JH JH JH JH+ JH JH JHZ 	  ge3
 G         
d
A d
A d
A d
A d
A.0B30Gd
A d
A d
AN    !"%'9"'=   &55 55 55 55 55 22 6 55 55 55pG G G G G(, G G GT    ob!#5b#9     rU   