U kf@spdZddlmZddlmZddlmZddlmZddZ d d Z d d Z d dZ ddZ ddZddZdS)zgprivate module containing functions used for copying data between instances based on join conditions. ) annotations)exc)util) PassiveFlagc Cs|j}|j}|D]\} } z(|j| } |j| jj||tj} Wn6tj k rv} zt d|| || | W5d} ~ XYnXz(|j| } |j| jj ||| dWn6tj k r} zt d|| || | W5d} ~ XYnX|r| j r| j r| | rd|jd|| f<qdS)NFTZ pk_cascaded)dict_columntopropertymanagerkeyimplgetr PASSIVE_OFFrUnmappedColumnError_raise_col_to_propset primary_keyZ references attributes)source source_mapperdest dest_mappersynchronize_pairs uowcommitZflag_cascaded_pks source_dictZ dest_dictlrpropvalueerrrC/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/orm/sync.pypopulates4   $ $r!c Cs|D]\}}z|j|}||j}Wn6tjk rZ}ztd|||||W5d}~XYnXz|j|}|||j<Wqtjk r}ztd|||||W5d}~XYqXqdS)NFT)rr rrr)rrrrrrrrrrr bulk_populate_inherit_keysAs  $ r"c Cs|D]\}}|jrJ|||j|tjkrJtd|d|dt|dz|||j|dWqtj k r}zt dd||||W5d}~XYqXqdS)NzDependency rule on column 'z)' tried to blank-out primary key column 'z' on instance ''T) r_get_state_attr_by_columnrorm_utilZ _none_setAssertionErrorZ state_strZ_set_state_attr_by_columnrrr)rrrrrrrrr clearQs r'c Cs|D]\}}z*|||}|j||j|tjd}Wn6tjk rl} ztd||d|| W5d} ~ XYnX|||j <||||j <qdSN)ZpassiveF) Z_get_committed_attr_by_columnobjr$rrr rrrr ) rrrZ old_prefixrrrZoldvaluerrrrr updatecs   $ r*c Csn|D]d\}}z|j||j|tjd}Wn6tjk r\}ztd||d||W5d}~XYnX|||j<qdSr()r$rrr rrrr )rrZdict_rrrrrrrr populate_dictrs  $r+c Csz|D]p\}}z|j|}Wn6tjk rP}ztd||d||W5d}~XYnX|||jtj}t|j rdSqdS)zpreturn true if the source object has changes from an old to a new value on the given synchronize pairs FNT) rrrrZget_attribute_historyr rZPASSIVE_NO_INITIALIZEboolZdeleted) rrrrrrrrhistoryrrr source_modified~s $ r.cCs4|rtd||f|ntd|||f|dS)NzCan'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).zCan'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).)rr)ZisdestrZ source_columnrZ dest_columnrrrr rsrN)__doc__ __future__rrrr%baserr!r"r'r*r+r.rrrrr  s    +