
    +h                     b    d Z ddlmZ ddlmZ ddlmZ ddlmZ d Zd Zd Zd	 Z	d
 Z
d Zd Zy)zgprivate module containing functions used for copying data
between instances based on join conditions.

   )
attributes)exc)util   c           
         | j                   }|j                   }|D ]  \  }	}
	 |j                  |	   }| j                  |j                     j                  j                  | |t        j                        }	 |j                  |
   }|j                  |j                     j                  j                  ||d        |s|	j                  s|
j                  s|
j                  |	      sd|j                  d||
f<    y # t        j                  $ r}t        d||	||
|       Y d }~d }~ww xY w# t        j                  $ r}t        d||	||
|       Y d }~d }~ww xY w)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errs                 F/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/orm/sync.pypopulater$      s@    ++K		I! B1	M 2215DNN488,1155Z%;%;E	L003DLL"''++D)UDI Q=AI  -q!9:9B && 	MumQQLL	M && 	Lt]A{AsKK	Ls1   AC<4AD,<D)D$$D),E?EEc           
      D   |D ]C  \  }}	 |j                   |   }| |j                     }	 |j                   |   }| |j                  <   E y # t        j                  $ r}t	        d|||||       Y d }~Jd }~ww xY w# t        j                  $ r t	        d||||       Y w xY w)NFT)r
   r   r   r   r   )r   r   r   r   r   r    r!   r"   s           r#   bulk_populate_inherit_keysr&   >   s    ! I1	O 2215D)E	I 2215D$)K!I && 	OumQq#NN	O && 	It]A}aH	Is(   A
A:
A7A22A7:"BBc           
      r   |D ]  \  }}|j                   rR|j                  | | j                  |      t        j                  vr%t        d|dt        j                  |       d      	 |j                  | | j                  |d         y # t        j                  $ r}t        dd ||||       Y d }~d }~ww xY w)Nz7Dependency rule tried to blank-out primary key column 'z' on instance ''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"   s         r#   clearr/   N   s    ! C1MM55dDIIqI%%& !23X5G5G5MO 	C11$		1dKC && 	CtT1k1cBB	Cs   (B		B6B11B6c           
      V   |D ]t  \  }}	 |j                  | j                         |      }|j                  | | j                  |t        j
                        }||j                  <   |||j                  z   <   v y # t        j                  $ r}	t        d||d ||	       Y d }	~	Ld }	~	ww xY wN)passiveF)
_get_committed_attr_by_columnobjr)   r	   r   r   r   r   r   r   )
r   r   r   
old_prefixr   r   r   oldvaluer!   r"   s
             r#   updater7   `   s    ! ,1	F$BB

aH ";;Q
0F0F < E
 QUU#+Z!%% , && 	FumQaEE	Fs   AA;;B(B##B(c           
          |D ]B  \  }}	 |j                  | | j                  |t        j                        }||j                  <   D y # t        j
                  $ r}t        d||d ||       Y d }~:d }~ww xY wr1   )r)   r	   r   r   r   r   r   r   )r   r   dict_r   r   r   r!   r"   s           r#   populate_dictr:   o   s    ! 1	F!;;Q
0F0F < E aee
 && 	FumQaEE	Fs   -A		A6A11A6c           
         |D ]W  \  }}	 |j                   |   }| j	                  |j
                  t        j                        }t        |j                        sW y y# t        j                  $ r}t        d||d||       Y d}~md}~ww xY w)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    r"   historys	            r#   source_modifiedrA   {   s    
 " 1	F 2215D 11DHHj>>
    && 	FumQaEE	Fs   AB1BBc                     | r2t        j                  t        j                  d|d|d      |       y t        j                  t        j                  d|d|d|d      |       y )Nz0Can't execute sync rule for destination column 'z'; mapper 'z' does not map this column.  Try using an explicit `foreign_keys` collection which does not include this column (or use a viewonly=True relation).)replace_contextz+Can't execute sync rule for source column 'zx' does not map this column.  Try using an explicit `foreign_keys` collection which does not include destination column 'z$' (or use a viewonly=True relation).)r   raise_r   r   )isdestr   source_columnr   dest_columnr"   s         r#   r   r      sb     ##
 1<[	J  		
 	## !->  
	
    N)__doc__ r   r   r   r*   r$   r&   r/   r7   r:   rA   r    rH   r#   <module>rL      s?   
    (BVI C$,	&
rH   