o
    y¬´\   ã                   @   sd   d Z ddlmZ ddlmZ ddlmZ dd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )zgprivate module containing functions used for copying data
between instances based on join conditions.

é   )Ú
attributes)Úexc)Úutilc              
   C   sä   | j }|j }|D ]g\}	}
z|j|	 }| j|j j | |tj¡}W n tj	y2   t
d||	||
ƒ Y nw z|j|
 }|j|j j |||d ¡ W n tj	yY   t
d||	||
ƒ Y nw |ro|	jro|
jro|
 |	¡rod|jd||
f< qd S )NFTÚpk_cascaded)ÚdictÚ_columntopropertyÚmanagerÚkeyÚimplÚgetr   ÚPASSIVE_OFFr   ÚUnmappedColumnErrorÚ_raise_col_to_propÚsetÚprimary_keyÚ
references)ÚsourceÚsource_mapperÚdestÚdest_mapperÚsynchronize_pairsÚ	uowcommitÚflag_cascaded_pksÚsource_dictÚ	dest_dictÚlÚrÚpropÚvalue© r   úE/var/www/html/env/lib/python3.10/site-packages/sqlalchemy/orm/sync.pyÚpopulate   s8   	
ÿÿ
ÿ	ÿþýü€är!   c              
   C   sŒ   |D ]A\}}z|j | }| |j }W n tjy$   td||||ƒ Y nw z|j | }|| |j< W q tjyC   td||||ƒ Y qw d S )NFT)r   r	   r   r   r   )r   r   r   r   r   r   r   r   r   r    Úbulk_populate_inherit_keys=   s   
ÿ
ÿör"   c              
   C   s~   |D ]:\}}|j r| | | j|¡tjvrtd|t | ¡f ƒ‚z| | | j|d ¡ W q tj	y<   t
dd |||ƒ Y qw d S )NzKDependency rule tried to blank-out primary key column '%s' on instance '%s'T)r   Ú_get_state_attr_by_columnr   Úorm_utilÚ	_none_setÚAssertionErrorÚ	state_strÚ_set_state_attr_by_columnr   r   r   )r   r   r   r   r   r   r   r    ÚclearM   s"   ÿÿÿÿÿór)   c           	   
   C   sz   |D ]8\}}z|  |  ¡ |¡}|j| | j|tjd�}W n tjy-   td||d |ƒ Y nw |||j	< ||||j	 < qd S ©N)ÚpassiveF)
Ú_get_committed_attr_by_columnÚobjr#   r   r   r   r   r   r   r	   )	r   r   r   Ú
old_prefixr   r   r   Úoldvaluer   r   r   r    Úupdate_   s   ÿ
ÿÿ
õr0   c              
   C   s\   |D ])\}}z|j | | j|tjd�}W n tjy%   td||d |ƒ Y nw |||j< qd S r*   )r#   r   r   r   r   r   r   r	   )r   r   Údict_r   r   r   r   r   r   r    Úpopulate_dictn   s   
ÿÿør2   c              
   C   sh   |D ]/\}}z|j | }W n tjy   td||d|ƒ Y nw |  ||jtj¡}t|j	ƒr1 dS qdS )zpreturn true if the source object has changes from an old to a
    new value on the given synchronize pairs

    FNT)
r   r   r   r   Úget_attribute_historyr	   r   ÚPASSIVE_NO_INITIALIZEÚboolÚdeleted)r   r   r   r   r   r   r   Úhistoryr   r   r    Úsource_modifiedz   s   ÿ
ÿ
ÿr8   c                 C   s*   | rt  d||f ¡‚t  d|||f ¡‚)NzÑCan't execute sync rule for destination column '%s'; mapper '%s' does not map this column.  Try using an explicit `foreign_keys` collection which does not include this column (or use a viewonly=True relation).zØCan't execute sync rule for source column '%s'; mapper '%s' does not map this column.  Try using an explicit `foreign_keys` collection which does not include destination column '%s' (or use a viewonly=True relation).)r   r   )Úisdestr   Úsource_columnr   Údest_columnr   r   r    r   �   s   üÿûÿr   N)Ú__doc__Ú r   r   r   r$   r!   r"   r)   r0   r2   r8   r   r   r   r   r    Ú<module>   s   +