
    rZh                    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.

    )annotations   )exc)util)PassiveFlagc           
        | 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
attributes)sourcesource_mapperdestdest_mappersynchronize_pairs	uowcommitflag_cascaded_pkssource_dict	dest_dictlrpropvalueerrs                 o/var/www/html/wine-match-dev/backend/winematch-backend/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[%<%<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           
     T   |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 d }~d }~ww xY w)NFT)r   r   r   r   r   )r   r   r   r    r!   r"   r#   r$   s           r%   bulk_populate_inherit_keysr(   A   s    ! N1	O 2215D)E	N 2215D$)K!N && 	OumQq#NN	O && 	Nt]A}aMM	Ns.   A
A:
A7A22A7:B'B""B'c                x   |D ]  \  }}|j                   rU|j                  | | j                  |      t        j                  vr(t        d| d| dt        j                  |        d      	 |j                  | | j                  |d         y # t        j                  $ r}t        dd ||||       Y d }~d }~ww xY w)NzDependency rule on column 'z)' 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%   clearr1   Q   s    ! C1MM55dDIIqI%%& !-aS 1#_X-?-?-E,FaI 
	C11$		1dKC && 	CtT1k1cBB	Cs   +BB9B44B9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%   updater9   c   s    ! ,1	F$BB

aH ";;Q0G0G < 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r3   )r+   r
   r   r   r   r   r   r   )r   r   dict_r   r    r!   r#   r$   s           r%   populate_dictr<   r   s    ! 1	F!;;Q0G0G < 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_modifiedrC   ~   s    
 " 1	F 2215D 11DHHk??
    && 	FumQaEE	Fs   AB1BBc           	         | rt        j                  d|d|d      |t        j                  d|d|d|d      |)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).z+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   r   )isdestr   source_columnr   dest_columnr$   s         r%   r   r      sT     %%
 -8	F
 	 %% m[:
 	    N)__doc__
__future__r    r   r   r,   baser   r&   r(   r1   r9   r<   rC   r    rH   r%   <module>rN      s?   
 #   (BVN C$,	&rH   