o znh@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}|D]g\} } z|j| } |j| jj||tj} Wntj y2t d|| || Ynwz|j| } |j| jj ||| dWntj yYt d|| || Ynw|ro| j ro| j ro| | rod|jd|| f<qdS)NFT pk_cascaded)dict_columntopropertymanagerkeyimplgetr PASSIVE_OFFrUnmappedColumnError_raise_col_to_propset primary_key references) source source_mapperdest dest_mappersynchronize_pairs uowcommitflag_cascaded_pks source_dict dest_dictlrpropvaluer>/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/sync.pypopulates8     r!c Cs|D]A\}}z |j|}||j}Wntjy$td||||Ynwz |j|}|||j<WqtjyCtd||||YqwdS)NFT)rr rr r)rrrrrrrrrr bulk_populate_inherit_keys=s   r"c Cs~|D]:\}}|jr|||j|tjvrtd|t|fz |||j|dWqtj y<t dd|||YqwdS)NzKDependency rule tried to blank-out primary key column '%s' on instance '%s'T) r_get_state_attr_by_columnrorm_util _none_setAssertionError state_str_set_state_attr_by_columnrr r)rrrrrrrr clearMs"  r)c Csz|D]8\}}z|||}|j||j|tjd}Wntjy-td||d|Ynw|||j <||||j <qdSN)passiveF) _get_committed_attr_by_columnobjr#rrr rr rr ) rrr old_prefixrrroldvaluerrrr update_s    r0c Cs\|D])\}}z |j||j|tjd}Wntjy%td||d|Ynw|||j<qdSr*)r#rrr rr rr )rrdict_rrrrrrr populate_dictns    r2c Csh|D]/\}}z|j|}Wntjytd||d|Ynw|||jtj}t|j r1dSqdS)zpreturn true if the source object has changes from an old to a new value on the given synchronize pairs FNT) rrr rget_attribute_historyr rPASSIVE_NO_INITIALIZEbooldeleted)rrrrrrrhistoryrrr source_modifiedzs   r8cCs*|r td||ftd|||f)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 )isdestr source_columnr dest_columnrrr rsrN) __doc__rrrr$r!r"r)r0r2r8rrrrr s   +