B 4]@sddZddlmZddlmZddlmZddZddZd d Zd d Z d dZ ddZ ddZ dS)zgprivate module containing functions used for copying data between instances based on join conditions. ) attributes)exc)utilc Cs|j}|j}x|D]\} } y(|j| } |j| jj||tj} Wn&tj k rht d|| || YnXy(|j| } |j| jj ||| dWn&tj k rt d|| || YnX|r| j r| j r| | rd|jd|| f<qWdS)NFTZ pk_cascaded)dict_columntopropertyZmanagerkeyimplgetr PASSIVE_OFFrUnmappedColumnError_raise_col_to_propset primary_keyZ references) source source_mapperdest dest_mappersynchronize_pairs uowcommitZflag_cascaded_pks source_dictZ dest_dictlrpropvaluerF/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/orm/sync.pypopulates&    rc Csx|D]\}}y|j|}||j}Wn&tjk rLtd||||YnXy|j|}|||j<Wqtjk rtd||||YqXqWdS)NFT)rrrr r )rrrrrrrrrrbulk_populate_inherit_keys=s  rc Csx|D]x\}}|jr@|||j|tjkr@td|t|fy|||j|dWqtj k r|t dd|||YqXqWdS)NzKDependency rule tried to blank-out primary key column '%s' on instance '%s'T) r_get_state_attr_by_columnrorm_utilZ _none_setAssertionErrorZ state_strZ_set_state_attr_by_columnrr r )rrrrrrrrclearMsr!c Csxz|D]r\}}y*|||}|j||j|tjd}Wn&tjk r^td||d|YnX|||j <||||j <qWdS)N)passiveF) Z_get_committed_attr_by_columnobjrrrr rr r r) rrrZ old_prefixrrrZoldvaluerrrrupdate_s  r$c Csbx\|D]T\}}y|j||j|tjd}Wn&tjk rNtd||d|YnX|||j<qWdS)N)r"F)rrrr rr r r)rrZdict_rrrrrrr populate_dictnsr%c Cspxj|D]^\}}y|j|}Wn&tjk rBtd||d|YnX|||jtj}t|j rdSqWdSdS)zpreturn true if the source object has changes from an old to a new value on the given synchronize pairs FNT) rrr r Zget_attribute_historyrrZPASSIVE_NO_INITIALIZEboolZdeleted)rrrrrrrhistoryrrrsource_modifiedzs r(cCs0|rtd||fntd|||fdS)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 sr N) __doc__rrrrrrr!r$r%r(r rrrr s   +