
    ,h                      S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SS	KJ
r
  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   SSK!J"r"  SSK!J#r#  SSK!J$r$  SSK!J%r%  SS K!J&r&  SS!K!J'r'  SS"K(J)r)  SS#K(J*r*  SS$K(J+r+  SS%K,J-r-  SS&K,J.r.  SS'K,J/r/  SS(KJ0r0  SS)K1J2r2  \
(       aH  SS*K3J4r4  SS+K3J5r5  SS,K3J6r6  SS-K7J8r8  SS.K9J:r:  SS/K9J;r;  SS0K9J<r<  SS1K9J=r=  SS2K>J?r?  SS3KJ@r@  SS4KJArA  SS5KBJCrC  \" S6\DS79rE\	S8S8S9.                 SRS: jj5       rF\	S8S8S9.                 SSS; jj5       rFS<S<S9.                 STS= jjrF\	S8S>S?.               SUS@ jj5       rG\	S8S>S?.               SVSA jj5       rGS<S>S?.               SWSB jjrGSC rH " SD SE\5      rI " SF SG\I5      rJ\*R                  " SHSI5       " SJ SK\I\.5      5       rL\*R                  " SHSL5       " SM SN\J\/5      5       rM\*R                  " SHSO5       " SP SQ\J\-5      5       rNg<)Xzoadditional ORM persistence classes related to "bulk" operations,
specifically outside of the flush() process.

    )annotations)Any)cast)Dict)Iterable)Optional)overload)TYPE_CHECKING)TypeVar)Union   )
attributes)context)	evaluator)exc)loading)persistence)NO_VALUE)AbstractORMCompileState)FromStatement)ORMFromStatementCompileState)QueryContext   )util)Dialect)result)	coercions)dml)
expression)roles)select)sqltypes)_entity_namespace_key)CompileState)Options)DeleteDMLState)InsertDMLState)UpdateDMLState)
EMPTY_DICT)Literal)DMLStrategyArgument)OrmExecuteOptionsParameter)SynchronizeSessionArgument)Mapper)_BindArguments)ORMExecuteState)Session)SessionTransaction)InstanceState)
Connection)cursor)_CoreAnyExecuteParams_O)bound.)use_orm_insert_stmtexecution_optionsc                   g N mappermappingssession_transactionisstatesreturn_defaultsrender_nullsr9   r:   s           W/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/orm/bulk_persistence.py_bulk_insertrF   J   s         c                   g r<   r=   r>   s           rE   rF   rF   X   s      #rG   Nc               F  ^ ^ T R                   nUR                  R                  (       a  [        S5      eU(       a  [        (       a  [        [        [        [              U5      nU(       a4  U V	s/ s H  oU	R                  4PM     n
n	U
 V	Vs/ s H  u  pUPM	     nn	nOU V	s/ s H  oR                  PM     nn	Oi[        (       a$  [        [        [        [        [        4      U5      nU(       a  [        U5      nOU Vs/ s H  n[        U5      PM     nn[        T U5        UR                  U5      mS nUR                   R#                  5        VVs/ s H  u  pUT R$                  ;   d  M  X4PM     nnnU(       a  SnO['        U5      S:  a  SnOSnU H  u  nnUb@  UR)                  5        Vs/ s H$  nUR*                  US   ;   d  M  UR*                  PM&     snOSnUU 4S j[,        R.                  " UUU 4S jU 5       SUUUS	9 5       n[,        R0                  " US UUUUUUS
9nUc  M  UR2                  (       a  Uc  UnM  UR4                  (       d  M  U(       d   eUR7                  U5      nM     U(       ak  U(       ad  T R8                  nT R:                   Vs/ s H  nUR*                  PM     nnW
 H,  u  pU[=        U Vs/ s H  nUU   PM
     sn5      S 4U	l        M.     Ub  Uc   eU$ g s  sn	f s  snn	f s  sn	f s  snf s  snnf s  snf s  snf s  snf )NzJconnection_callable / per-instance sharding not supported in bulk_insert()Tr   Fr   r=   c           	   3  J   >#    U  H  u  nnnnnnnnS UUT
T	UUU4v   M     g 7fr<   r=   ).0state
state_dictparamsmpconnvalue_paramshas_all_pkshas_all_defaults
connectionr?   s            rE   	<genexpr>_bulk_insert.<locals>.<genexpr>   sQ      
(	 #  	&s    #c              3  0   >#    U  H  nS UTT4v   M     g 7fr<   r=   rK   mappingrT   r?   s     rE   rU   rV      s     MH$4Hs   )bulkrC   rD   include_bulk_keys)bookkeepingr9   r:   )base_mappersessionconnection_callableNotImplementedErrorr
   r   r   r3   r7   dictr   strr   list_expand_compositesrT   _sorted_tablesitems_pks_by_tablelen_get_embedded_bindparamskeyr   _collect_insert_commands_emit_insert_statements
_returningreturns_rowssplice_horizontally_identity_class_identity_key_propstuple)r?   r@   rA   rB   rC   rD   r9   r:   r]   rL   statesdict_mreturn_resulttablerO   mappers_to_runr\   super_mapperbextra_bp_namesrecordsr   identity_clspidentity_propsrj   rT   s   `                          @rE   rF   rF   f   s    $$K""66!-
 	

 =H]2%67BH7?@xeejj)xF@4:;F.5FH;H089u

H9H=HT#s(^4h?H H~H *22AQH268,$//<J8<M %3399;;IEF((( 	;   	^	q	  -| #. -EEGGA55HQK' G  	
( 55MHM +)"0)
< 44# 3/	
 *&11]5J &$$$""{ - A A& I  .B 8--)/)C)CD)CA!%%)CD"LE^<^cuSz^<=EI # &((( 'u A;9( 34t E =s<   0K9K>$LL	L/L4LL$LLT)use_orm_update_stmtenable_check_rowcountc                   g r<   r=   r?   r@   rA   rB   update_changed_onlyr   r   s          rE   _bulk_updater      s     rG   c                   g r<   r=   r   s          rE   r   r     s     rG   c                 ^ ^^ T R                   nT R                  mT R                  (       a&  T R                  R                  1R	                  T5      mU4S jnU(       a<  U(       a  U V	s/ s H  o" T U	5      PM     nn	OCU V	s/ s H  oR
                  PM     nn	O'U V
s/ s H  n
[        U
5      PM     nn
[        T U5        UR                  R                  (       a  [        S5      eUR                  U5      mUb@  UR                  5        Vs/ s H$  nUR                  US   ;   d  M  UR                  PM&     snOSnUR                  R                  5        Hl  u  pT R                  U5      (       a  UT R                  ;  a  M-  [         R"                  " S UUU 4S jU 5       SUUS9n[         R$                  " US UUUSUUS	9  Mn     Ub  [&        R(                  " 5       $ g s  sn	f s  sn	f s  sn
f s  snf )
Nc                   > UR                   R                  5        VVs0 s H  u  p#X!R                  ;   d  UT;   d  M  X#_M      snn$ s  snnf r<   )ra   rf   committed_state)r?   rL   kvsearch_keyss       rE   _changed_dict#_bulk_update.<locals>._changed_dict(  sP     

((*
*)))Q+-= AD*
 	
 
s
   AAzJconnection_callable / per-instance sharding not supported in bulk_update()r   r=   c              3     >#    U  H6  nS UTTTR                   (       a  UTR                   R                     OS 4v   M8     g 7fr<   )_version_id_proprj   rX   s     rE   rU   _bulk_update.<locals>.<genexpr>S  sN        (G  "22   7 7 ; ;<!
  (s   >AT)rZ   r   r[   F)r\   r   r   )r]   _primary_key_propkeysr   rj   unionra   rd   r^   r_   r`   rT   ri   re   rf   isarg   r   _collect_update_commands_emit_update_statements_resultnull_result)r?   r@   rA   rB   r   r   r   r]   r   rL   ru   rz   r{   rw   ry   r|   rT   r   s   `               @@rE   r   r     s    $$K..K..22399+F
 BJK(fe4(HKH089u

H9H%-.XDGX.68,""66!-
 	

 %//<J * )AAC	
Cuu# AEEC	
    +99??Azz,''58L8L+L66  (  3,'
* 	++ 3"7		
3  BH &""$$ ' L9.	
s   +G"G' G,G1*G1c                   U R                   nU(       d  g [        UR                  5       5      nU Vs0 s H  nXBU   R                  5       _M     nnU H%  nUR	                  U5       H  nXT   " U5        M     M'     g s  snf r<   )
compositessetkeys)_populate_composite_bulk_save_mappings_fnintersection)r?   r@   composite_attrscomposite_keysrj   
populatorsrY   s          rE   rd   rd   t  s    ''O--/0N "!C 	S!KKMM!   !..w7COG$ 8 	s   A=c                      \ rS rSr% SrSrS\S'   \S 5       r\S 5       r	\S 5       r
\S	 5       r\S
 5       rSS.S jr\S 5       rSrg)ORMDMLStatei  TNz&Optional[ORMFromStatementCompileState]from_statement_ctxc           	   #  8  #    [         R                  nU GH{  u  pg[        R                  " [        R
                  U5      n[        U[        5      (       a  [        X[        S9nU[        L aj  [        R                  " [        R
                  U5      U(       a8  [        R                  " [        R                  U[        R                  " 5       SS9OU4v   M  U" UUR                  U5      U5       S h  vN   M  SUR                  ;   aB  UR                  n	[        U	S   U	S   5      n
U" UU
R                  U5      U5       S h  vN   GM6  UU(       d  UO7[        R                  " [        R                  U[        R                  " 5       SS94v   GM~     g  N NT7f)N)defaultT)type_is_crudentity_namespace	proxy_key)r(   _get_crud_kv_pairsr   expectr    DMLColumnRole
isinstancerb   r#   r   ExpressionElementRoler"   NullType_bulk_update_tuples_annotations)clsr?   	statementkv_iteratorneeds_to_be_cacheablecore_get_crud_kv_pairsr   r   desck_annoattrs              rE   _get_orm_crud_kv_pairs"ORMDMLState._get_orm_crud_kv_pairs  s{     "0!B!BDA  !4!4a8A!S!!,VI8#!(()<)<a@  5 &,, % ; ; !&.&7&7&9(,	 "#   6!003-   
 $q~~5,-.{0C 2,,Q/)     5 &--!77"*"3"3"5$(	 I  (s&   C0F2F3AFFAFFc                   UR                   S   nU(       a  UR                  (       d  [        R                  " X5      $ U Vs/ s H7  n[	        U R                  UR                  XR                  5       S5      5      PM9     sn$ s  snf )Nplugin_subjectF)_propagate_attrsr?   r(   _get_multi_crud_kv_pairsra   r   rf   )r   r   r   r   
value_dicts        rE   r   $ORMDMLState._get_multi_crud_kv_pairs  s    "334DE^%:%:!::  *
 *
 **"))96F6F6H%
 *
 	
 
s   >Bc                    U(       d   S5       eUR                   S   nU(       a  UR                  (       d  [        R                  " XU5      $ [	        U R                  UR                  UUU5      5      $ )Nz0no test coverage for needs_to_be_cacheable=Falser   )r   r?   r(   r   rc   r   )r   r   r   r   r   s        rE   r   ORMDMLState._get_crud_kv_pairs  s}     "	>=	>! #334DE^%:%:!44(=  &&%%%	
 	
rG   c                   UR                   R                  S   nUR                  nUR                  (       a  UR                  nOUR
                  R                  nUUR
                  UR                  UR                  UR                  S.$ )Nparententity)nametypeexprentityrw   )	rw   r   r?   is_aliased_classr   class___name__r   local_table)r   r   ext_infor?   _label_names        rE   get_entity_description"ORMDMLState.get_entity_description  sm    ??//?$$"--K --00K  MMOOoo''
 	
rG   c           
         S nS nUR                    Vs/ s H  oDU" U5      4PM     sn VVs/ s H;  u  pEUR                  UR                  U" XE5      UR                  UR                  S.PM=     snn$ s  snf s  snnf )Nc                :    U R                   R                  SS 5      $ )Nr   )r   get)cs    rE   _ent_for_colCORMDMLState.get_returning_column_descriptions.<locals>._ent_for_col  s    >>%%nd;;rG   c                    Uc  U $ U R                   R                  SS 5      nU(       d  U $ [        UR                  X 5      $ )Nr   )r   r   getattrr   )r   entr   s      rE   _attr_for_colDORMDMLState.get_returning_column_descriptions.<locals>._attr_for_col  s;    {**;=Iszz988rG   )r   r   r   aliasedr   )_all_selected_columnsrj   r   r   r   )r   r   r   r   r   r   s         rE   !get_returning_column_descriptions-ORMDMLState.get_returning_column_descriptions  s    	<	9$ /8.M.M.MLO$.M
 %a-//**
 	

s   A4AA9)use_supplemental_colsc               J   UR                   (       Ga  [        UR                   USS9nUR                  " S0 UR                  D6nUR                  " UR
                  6 nX`l        [        R                  " Xa5      =U l	        nUR                  U5        UR                  5       nSUl         UR                   Vs/ s H	  oc  M  UPM     n	nU	(       d  U	R                  UR                  5        U(       a  UR                  " UR                  SU	06nU$ UR                   " U	6 nU$ s  snf )a<  establish ORM column handlers for an INSERT, UPDATE, or DELETE
which uses explicit returning().

called within compilation level create_for_statement.

The _return_orm_returning() method then receives the Result
after the statement was executed, and applies ORM loading to the
state that we first established here.

F)_adapt_on_namesr=   supplemental_cols)rm   r   r:   _execution_optionsoptions_with_optionsselect_statementr   create_for_statementr   !setup_dml_returning_compile_state	_generateprimary_columnsextendprimary_keyrC   	returning)
selfcompilerorm_level_statementdml_level_statement
dml_mapperr   fsfscr   cols_to_returns
             rE   _setup_orm_returning ORMDMLState._setup_orm_returning  s,   ( )))#..# %B
 %%O(;(N(NOB0>>?B$&!,AA"OD#c 11*="5"?"?"A-/*),)<)<N)<Aa)<NN "%%j&<&<=$&9&I&I  ++' '5'#( #"	 ':&C&C#'# #"9 Os   6D  D c           
     n   UR                   nUR                  R                  nUR                  (       a  UR                  R                  R
                  (       d\  UR                  S[        R                  5      n	[        UR                  UR                  UUUU	UU5      n
[        R                  " Xj5      $ U$ )N_sa_orm_load_options)r   compiledcompile_stater   compile_options_is_starr   r   default_load_optionsr   r   	instances)r   r^   r   rN   r:   bind_argumentsr   execution_contextr   load_optionsquerycontexts              rE   _return_orm_returning!ORMDMLState._return_orm_returningV  s     #NN)22@@ ,,!44DDMM,00&(I(IL (00..!	L $$V::MrG   )r   r   )r   
__module____qualname____firstlineno__is_dml_returningr   __annotations__classmethodr   r   r   r   r   r   r  __static_attributes__r=   rG   rE   r   r     s    AE>E5 5n 
 
" 
 
* 
 
  
 
B #A#F    rG   r   c                     \ rS rSr " S S\5      r\SSSSS.             SS jj5       r\S 5       r\S 5       r	\S	 5       r
\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)BulkUDCompileStateiz  c                      \ rS rSr% SrS\S'   SrS\S'   SrS\S	'   SrS\S
'   Sr	S\S'   Sr
S\S'   SrS\S'   \rSrSrSrSrS\S'   Srg))BulkUDCompileState.default_update_optionsi{  autor+   _dml_strategyr-   _synchronize_sessionFbool_can_use_returning_is_delete_using_is_update_fromT
_autoflushNOptional[Mapper[Any]]_subject_mapper_populate_existingr=   )r   r	  r
  r  r  r  r  r  r  r  r  r  r)   _resolved_values_eval_condition_matched_rows_identity_tokenr  r  r=   rG   rE   default_update_optionsr  {  sn    -3*3;A8A#(D(!&$& %%
D15.5%#(D(rG   r#  Fis_multitableis_update_fromis_delete_usingis_executemanyc                   [        5       er<   )r`   )r   dialectr?   r%  r&  r'  r(  s          rE   can_use_returning$BulkUDCompileState.can_use_returning  s     "##rG   c                Z   [         R                  R                  S1 SkUUR                  5      u  nnX%S'    UR                  S   nU(       a   UR
                  US'   USUR
                  0-  nSUR                  R                  ;  a  US	S
0-  nOk[        U[        5      (       d?  UR                  S:X  a  US	S0-  nO>UR                  S:X  a  [        R                  " S5      eOUR                  S:X  a  US	S0-  nUR                  n	U	bH  U	S;  a  [        R                  " S5      eUR                  S:X  a  U	S:X  a  [        R                  " S5      eU(       Gd  UR                   (       a  UR!                  5         UR                  S:X  au  UR                  S:X  a  U R#                  UUUUUU5      nOuUR                  S:X  a  U R%                  UUUUUU5      nONUR                  S:X  a  U R'                  UUUUUU5      nO'UR                  S:X  a  UR                  S:X  a  USS0-  nUR)                  UR                  UR*                  UR,                  UR                  UR.                  S.5      nU[0        R2                  " U5      R5                  SU05      4$ ! [         a     S5       ef = f)N_sa_orm_update_options>   	autoflushdml_strategyidentity_tokenr&  r'  populate_existingsynchronize_sessionclauser   r?   r  0statement had 'orm' plugin but no plugin_subjectr   r  	core_onlyr  ormrZ   HCan't use "bulk" ORM insert strategy without passing separate parameters)r  evaluatefetchFzSValid strategies for session synchronization are 'auto', 'evaluate', 'fetch', Falser:  zkThe 'fetch' synchronization strategy is not available for 'bulk' ORM updates (i.e. multiple parameter sets)r9  r  )r3  r'  r&  r0  r+  )r  r#  from_execution_optionsr   r   r?   KeyErrorrw   r   r   rc   r  sa_excInvalidRequestErrorr  ArgumentErrorr  _do_pre_synchronize_auto_do_pre_synchronize_evaluate_do_pre_synchronize_fetch	_annotater  r  r  r   immutabledictr   )
r   r^   r   rN   r:   r  is_pre_eventupdate_optionsr   syncs
             rE   orm_pre_session_exec'BulkUDCompileState.orm_pre_session_exec  s    55LL$ ((
	
 $-x 	M&778HIN +9+@+@x(#4n6K6K"LL!=!==<<NFD))++v5?E"::--7002  8 ++v5?F";;22??**=  ++v5$'/00L 
 ((""$++u4!66&@%(%A%A!)&&&N $88JF%(%E%E!)&&&N $88GC%(%B%B!)&&&N  --7!66&@"'=z&JJN "+++9+N+N'5'F'F&4&D&D$2$@$@)7)J)JI 0177)>:
 	
i  	MLLL5	Ms   J J*c                L   US   nUR                   S:X  aF  UR                  S:X  a  U R                  XXg5        OWUR                  S:X  a  U R                  XXg5        O4UR                   S:X  a$  UR                  S:X  a  U R	                  XXg5        U$ U R                  UUUUUU5      $ )Nr.  r7  r9  r:  rZ   )r  r  _do_post_synchronize_evaluate_do_post_synchronize_fetch"_do_post_synchronize_bulk_evaluater  )r   r^   r   rN   r:   r  r   rF  s           rE   orm_setup_cursor_result*BulkUDCompileState.orm_setup_cursor_result  s    $ ++CD''5022j@11  44?.. ))V322j@66V M((
 	
rG   c                X  ^^ SnTR                   (       a  TR                  OSmSTR                  4U;   a'  U[        U4S jUSTR                  4    5       5      -  nTR                  R                  b  UTR                  R                  4-  nT(       a  [        U4S jU 5       5      nU$ )a]  Apply extra criteria filtering.

For all distinct single-table-inheritance mappers represented in the
table being updated or deleted, produce additional WHERE criteria such
that only the appropriate subtypes are selected from the total results.

Additionally, add WHERE criteria originating from LoaderCriteriaOptions
collected from the statement.

r=   Nadditional_entity_criteriac              3     >#    U  H8  nUR                   (       d  UR                  TL d  M%  UR                  T5      v   M:     g 7fr<   )include_aliasesr   _resolve_where_criteria)rK   aer   s     rE   rU   @BulkUDCompileState._adjust_for_extra_criteria.<locals>.<genexpr>P  sB      !B %%h)>	 5**844s
   $AAc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr<   )traverse)rK   critadapters     rE   rU   rV  \  s     O;4 0 0 6 6;s   !)r   _adapterr?   rr   _single_table_criterion)r   global_attributesr   return_critrZ  s     ` @rE   _adjust_for_extra_criteria-BulkUDCompileState._adjust_for_extra_criteria;  s     '/'@'@(##d )OO
  5 !+18??C!  K ??22>HOOCCEEKO;OOKrG   c                ,    UR                   UR                  R                   La&  UR                  UR                   R                  5      nOUR                  UR                  5      n U Vs/ s H
  oT" U5      PM     sn$ ! [         a    / s $ f = fs  snf )a  return rows that indicate PK cols in mapper.primary_key position
for RETURNING rows.

Prior to 2.0.36, this method seemed to be written for some kind of
inheritance scenario but the scenario was unused for actual joined
inheritance, and the function instead seemed to perform some kind of
partial translation that would remove non-PK cols if the PK cols
happened to be first in the row, but not otherwise.  The joined
inheritance walk feature here seems to have never been used as it was
always skipped by the "local_table" check.

As of 2.0.36 the function strips away non-PK cols and provides the
PK cols for the table in mapper PK order.

)r   r]   _tuple_getterr   r<  )r   r   r?   rowspk_keysrows         rE   _interpret_returning_rows,BulkUDCompileState._interpret_returning_rows`  s    $	!!););)G)GG
 !..v/A/A/M/MN ..v/A/AB )----  	 I		 .s   AA? A? +B?BBc                2   UR                   nUR                  nU Vs/ s HT  nUR                  R                  U5      (       d  M%  UR                  (       a  M8  UR                  5       XUR                  4PMV     nnUR                  nUb-  U VVV	s/ s H  u  pn	UR                  U:X  d  M  XU	4PM     nnnn	/ n
U HM  u  pn	U" U5      nUSL d  U[        R                  L d  M(  U
R                  UUU	U[        R                  L 45        MO     U
$ s  snf s  sn	nnf NT)r  r   r?   r   expiredobjra   r"  r1  r   _EXPIRED_OBJECTappend)r   rF  rs   r?   eval_conditionrL   raw_datar1  rk  rt   r   evaled_conditions               rE    _get_matched_objects_on_criteria3BulkUDCompileState._get_matched_objects_on_criteria  s+   //'77  
||' -05 -UYY[%, 	 
 (77% *2)1%C''>9 $U#)1   !)C-c2
 !D(#y'@'@@(I,E,EE	 "*" A
s   $DD DD*Dc                   UR                   nUR                  n[        R                  " U5      nSnUR                  (       a  XbR                  -  n0 nUR
                   H'  nUR                  (       d  M  UR                  U5        M)     U(       a  X`R                  Xs5      -  nU(       a  UR                  " U6 n	U	$ S n
U
n	U	$ )Nr=   c                    gri  r=   )rk  s    rE   r   JBulkUDCompileState._eval_condition_from_statement.<locals>._eval_condition  s    rG   )
r  r   r   _EvaluatorCompiler_where_criteriar   _is_criteria_optionget_global_criteriar_  process)r   rF  r   r?   
target_clsevaluator_compilerrY  r]  optrn  r   s              rE   _eval_condition_from_statement1BulkUDCompileState._eval_condition_from_statement  s    //]]
&99*E$$---D**C&&&''(9: + 223DMMD/77>N  -NrG   c                     U R                  Xb5      nUUSS.-   $ ! [        R                   a     Of = fUSS0-  nU R                  UUUUUU5      $ )a  setup auto sync strategy


"auto" checks if we can use "evaluate" first, then falls back
to "fetch"

evaluate is vastly more efficient for the common case
where session is empty, only has a few objects, and the UPDATE
statement can potentially match thousands/millions of rows.

OTOH more complex criteria that fails to work with "evaluate"
we would hope usually correlates with fewer net rows.

r9  )r   r  r  r:  )r~  r   UnevaluatableErrorrB  )r   r^   r   rN   r:   r  rF  rn  s           rE   r@  +BulkUDCompileState._do_pre_synchronize_auto  s    2	 ??N "#1(2%   ++ 		 	17;;,,
 	
s    22c                     U R                  Xb5      nUSU0-   $ ! [        R                   a  n[        R                  " SU-  5      UeS nAff = f)Nz{Could not evaluate current criteria in Python: "%s". Specify 'fetch' or False for the synchronize_session execution option.r   )r~  r   r  r=  r>  )	r   r^   r   rN   r:   r  rF  rn  errs	            rE   rA  /BulkUDCompileState._do_pre_synchronize_evaluate  sp    
	 ??N ~!
 
 	
 ++ 	,,8:=> 		s    AAAc                    UR                   (       a  / $ UR                  (       a  [        UR                  5      $ UR                  (       a#  [        UR                  R	                  5       5      $ / $ r<   )_multi_values_ordered_valuesrc   _valuesrf   )r   r?   r   s      rE   _get_resolved_values'BulkUDCompileState._get_resolved_values  sR    ""I&&	1122	))//122IrG   c                .   / nU Hq  u  pEU(       aN  [        U[        R                  5      (       a/   UR                  U   nUR	                  UR
                  U45        MZ  [        R                  " SU-  5      e   U$ ! [        R                   a     M  f = f)NzCAttribute name not found, can't be synchronized back to objects: %r)
r   r   ColumnElement_columntopropertyrm  rj   orm_excUnmappedColumnErrorr=  r>  )r   r?   resolved_valuesvaluesr   r   r   s          rE   _resolved_keys_as_propnames.BulkUDCompileState._resolved_keys_as_propnames  s    #DA*Q
(@(@AA1!33A6D MM488Q-00079:;  $  22 s   A<<BBc                @  ^ ^^^ TR                   m[        TR                  TR                  4-   6 R	                  T5      R
                  " UR                  6 nUR                  Ul        S mSUU UU4S jjnUR                  UUUUUS9n	U	R                  5       n
TU
TS.-   $ )Nc                  > U R                   R                  " S0 U R                  D6nTR                  UR                  TTR
                  TR                  U R                  S9nTb  TU:w  a  [        R                  " S5      eO0U R                  (       a  U(       d  [        R                  " S5      eUmU(       a  [        R                  " 5       $ g )N)r&  r'  r(  zjFor synchronize_session='fetch', can't mix multiple backends where some support RETURNING and others don'tzFor synchronize_session='fetch', can't use multiple parameter sets in ORM mode, which this backend does not support with RETURNINGr=   )r^   get_bindr  r+  r*  r  r  r(  r=  r>  r   r   )orm_contextbindper_bind_resultr+  r   r?   rF  s      rE   skip_for_returningHBulkUDCompileState._do_pre_synchronize_fetch.<locals>.skip_for_returningP  s    &&//M+2L2LMD "33-== . ? ?*99 4 O !,$7 44   8 ++O00-  %4!**,,rG   )r:   r  
_add_event)r!  r  )r  r0   returnr   )
r  r!   r   select_identity_tokenselect_fromr   r   rw  executefetchall)r   r^   r   rN   r:   r  rF  select_stmtr  r   matched_rowsr+  r?   s   `     `    @@rE   rB  ,BulkUDCompileState._do_pre_synchronize_fetch.  s      // V''6+G+G*IIK[ W--/ 	
 '0&?&?# !	 	B /)) ! 
 ()"3!
 
 	
rG   r=   Nr*  r   r?   Mapper[Any]r%  r  r&  r  r'  r  r(  r  r  r  )r   r	  r
  r  r%   r#  r  r+  rH  rN  r_  rf  rq  r~  r@  rA  r  r  rB  r  r=   rG   rE   r  r  z  sZ   ) )  $$ %$
$
$ 
$
 
$ 
$ 
$ 
$ 

$ 
$ v
 v
p )
 )
V " "H  .  .D $ $L  8 -
 -
^ 
 
2    " N
 N
rG   r  r7  insertc                     ^  \ rS rSr%  " S S\5      rSrS\S'   \S 5       r	\              SS j5       r
\SU 4S	 jj5       r\S
 5       rS rS rSrU =r$ )BulkORMInserti  c                  j    \ rS rSr% SrS\S'   SrS\S'   SrS\S'   S	rS
\S'   Sr	S\S'   Sr
S\S'   Srg	)$BulkORMInsert.default_insert_optionsi  r  r+   r  Fr  _render_nulls_return_defaultsNr  r  Tr  r  r=   )r   r	  r
  r  r  r  r  r  r  r  r  r  r=   rG   rE   default_insert_optionsr    sB    -3*3#t#!&$&15.5
D#(D(rG   r  NzOptional[FromStatement]r   c                (   [         R                  R                  S1 SkUUR                  5      u  nnX%S'    UR                  S   nU(       a   UR
                  US'   USUR
                  0-  nU(       d?  UR                  S:X  a  US	S
0-  nO>UR                  S:X  a  [        R                  " S5      eOUR                  S:X  a  US	S0-  nUR                  S:w  a7  U(       d  [        R                  nOUR                  [        R                  5      nU(       d!  UR                  (       a  UR                  5         UR                  SUR                  05      nU[        R                   " U5      R                  SU05      4$ ! [         a     S5       ef = f)N_sa_orm_insert_options>   r/  r0  rD   r2  r4  r   r?   r  r5  r  r  r7  rZ   r8  rawr0  )r  r  r;  r   r   r?   r<  r  r=  r>  r   _orm_load_exec_optionsr   r  rC  r   rD  )	r   r^   r   rN   r:   r  rE  insert_optionsr   s	            rE   rH  "BulkORMInsert.orm_pre_session_exec  s    00GG$N((	
	
 $-x 	M&778HIN +9+@+@x(#4n6K6K"LL++v5?E"::--7002  8 ++v5?F";;''50 %$+$B$B!$5$;$;22%!  9 9 ''^99:
	
 0177)>:
 	
O  	MLLL5	Ms   E? ?Fc                   UR                  SU R                  5      nUR                  S;  a  [        R                  " S5      eUR                  S:X  a  UR                  X#=(       d    0 US9nU$ UR                  S:X  a  UR                  n	UR                  b*  U	R                  (       a  [        R                  " SU	 35      eU	c   eUR                  c   e[        U	[        S[        U[        5      (       a  U/OU5      UR                  S	UR                  UR                   UUS
9nO4UR                  S:X  a  UR                  X#=(       d    0 US9nO
[#        5       e[%        UR&                  5      (       d  U$ UR(                  (       a:  UR                  S[*        R,                  5      n
U
SS0-  n
UR/                  SU
05      nU R1                  UUUUUU5      $ )Nr  )r  rZ   r7  r  zHValid strategies for ORM insert strategy are 'raw', 'orm', 'bulk', 'autor  )r:   rZ   z`bulk INSERT with a 'post values' clause (typically upsert) not supported for multi-table mapper Iterable[Dict[str, Any]]F)rB   rC   rD   r9   r:   r7  r   r  T)r   r  r  r=  r?  r  r  _post_values_clause_multiple_persistence_tablesr>  _transactionrF   r   r   ra   r  r  AssertionErrorr  rm   r  r   r  r   r  )r   r^   r   rN   r:   r  rP   r  r   r?   r  s              rE   orm_execute_statement#BulkORMInsert.orm_execute_statement  s	    +..$c&@&@
 '' 0
 
 &&2  ''50\\<R;L " F M''61#33F --97700$X'  %%%''333!. *64 8 8VHf $$ . ? ?+99$-"3F ))U2\\<R;L " F !""I(())M,,,00&(I(IL 1488L 1 7 7'6! ((
 	
rG   c                <  > [        [        [        TU ]  " X40 UD65      nUb  UR                  (       + nOSnU(       d  U$ UR
                  S   nUR                  R                  SS5      nUS:X  a  UR                  U5        U$ US:X  a  UR                  X&5        U$ )NTr   r0  r  rZ   r7  )
r   r  superr   stackr   r   r   _setup_for_bulk_insert_setup_for_orm_insert)	r   r   r   kwr   toplevelr?   r0  	__class__s	           rE   r   "BulkORMInsert.create_for_statement)  s    G(CC

 #>>)HHK++,<= --11.%H6!''1  U"&&x8rG   c                   ^ U4S jUR                  5        5        VVVs0 s H  u  p4nUb  UR                  OUU_M     snnn$ s  snnnf )Nc              3  b   >#    U  H$  u  pTR                   R                  U5      X4v   M&     g 7fr<   )r   r   )rK   r   r   r?   s      rE   rU   ;BulkORMInsert._resolved_keys_as_col_keys.<locals>.<genexpr>D  s(      4ODAa!'4Os   ,/)rf   rj   )r   r?   resolved_value_dictcolr   r   s    `    rE   _resolved_keys_as_col_keys(BulkORMInsert._resolved_keys_as_col_keys@  sR    4G4M4M4O
	 CGGAq0
 	
 
s   Ac                    [        [        R                  U R                  5      =p4U R	                  UUUUSS9nX0l        g )NFr   r   )r   r   Insertr   r   )r   r   r?   r   r   s        rE   r  #BulkORMInsert._setup_for_orm_insertI  sD    *.szz4>>*JJ	--"' . 
	 #rG   c                   [        [        R                  U R                  5      =p#UR                  nUS   US   peUR                  5       nXRl        U R                  (       aE  U R                  R                  5        VVs0 s H  u  pxUR                  UL d  M  Xx_M     snnU l        U R                  UUUUSS9nU R                  b;  U R                  R                  R                  (       a  [        R                  " S5      eX l        gs  snnf )zestablish an INSERT statement within the context of
bulk insert.

This method will be within the "conn.execute()" call that is invoked
by persistence._emit_insert_statement().

_emit_insert_table_emit_insert_mapperTr  NzCan't use RETURNING * with bulk ORM INSERT.  Please use a different INSERT form, such as INSERT..VALUES or INSERT with a Core Connection)r   r   r  r   r   _clonerw   _dict_parametersrf   r   r   r   r   r=  CompileError)	r   r   r   r   anemit_insert_tableemit_insert_mapperr  vals	            rE   r  $BulkORMInsert._setup_for_bulk_insertU  s    +/szz4>>*JJ	## #$$% .
 $$&	+   !% 5 5 ; ; =% =HC99 11  =%D! --)"& . 
	 ##/''77@@%%3  #1%s   ?D	D	)r  r   )r^   r1   r   z
dml.InsertrN   r6   r:   r,   r  r/   rP   r4   r  _result.Result)r  r  )r   r	  r
  r  r%   r  r   r  r  rH  r  r   r  r  r  r  __classcell__r  s   @rE   r  r    s    ) ) 15-4A
 A
F V
V
 V
 &	V

 6V
 'V
 V
 
V
 V
p  , 
 

#,# ,#rG   r  updatec                     ^  \ rS rSr\S 5       rS rS r\              SU 4S jj5       r\SSSSS.             SS jj5       r	\S	 5       r
\S
 5       r\S 5       r\S 5       rSrU =r$ )BulkORMUpdatei  c                ~   U R                  U 5      nUR                  R                  SS5      nUR                  (       + nU(       a  US:X  a  UR	                  X5        U$ US:X  d   US:X  a4  SUR
                  R                  ;  a  [        R                  " XAU40 UD6  U$ U(       a  US;   a  UR                  X5        U$ )Nr0  unspecifiedrZ   r6  r   )r7  r  )	__new__r   r   r  _setup_for_bulk_updaterw   r(   __init___setup_for_orm_update)r   r   r   r  r   r0  r  s          rE   r   "BulkORMUpdate.create_for_statement  s    {{3 --11M
  ~~%.''	<  K'},ioo&B&BB##DXDD  \-CC&&y;rG   c                V   UnUR                   (       + nUR                  R                  S   nUR                  =U l        nU R	                  Xq5      U l        U R                  UUUUS9  UR                  (       a  [        U R
                  5      U l        UR                  5       nUR                  R                  S   UL a  UR                  Ul        UR                  (       a  U R
                  Ul        O"UR                  (       a  U R
                  Ul        U R                  U R                  U5      n	U	(       a  UR                  " U	6 n[        R                   " XU40 UD6  Sn
U(       d  S nOUR                  R#                  SS 5      nUR                  R#                  SS 5      nUSLa0  US:H  =(       a$    U R%                  UR&                  XpR(                  S9nUS:X  a,  U(       a%  Sn
UR*                  " UR                  R,                  6 nU(       a  U R/                  UUUUU
S	9nXl        g )
Nr   r  process_criteria_for_toplevelFr3  r+  r:  )r%  Tr  )r  rw   r   r?   r  r  _init_global_attributesr  ra   r  r   r  r_  r]  wherer(   r  r   r+  r*  r%  rC   r   r   r   )r   r   r   r  r   r  r   r?   new_stmtnew_critr   r3  r+  s                rE   r  #BulkORMUpdate._setup_for_orm_update  s   '~~%??//?'.f $ 9 9& L$$*2	 	% 	
 $()>)>$?D!##%>>&&~6&@#//HN $$'+'<'<H$#44H22""F
 ~~x0H 	?B? %"&"*"7"7";";%t# %1155
 E) $w. **$$f<N<N +   ').?$(!  //1K1KLH00#!&; 1 H "rG   c                   [        [        R                  U5      nUR                  nUS   US   peUR	                  5       nXQl        [        R                  " XU40 UD6  U R                  (       a  [        R                  " S5      eU R                  (       aE  U R                  R                  5        VVs0 s H  u  pxUR
                  UL d  M  Xx_M     snnU l        Xl        gs  snnf )zestablish an UPDATE statement within the context of
bulk insert.

This method will be within the "conn.execute()" call that is invoked
by persistence._emit_update_statement().

_emit_update_table_emit_update_mapperzbulk ORM UPDATE does not support ordered_values() for custom UPDATE statements with bulk parameter sets.  Use a non-bulk UPDATE statement or use values().N)r   r   Updater   r  rw   r(   r  r  r=  r>  r  rf   r   )	r   r   r   r  r  emit_update_table_r  r  s	            rE   r  $BulkORMUpdate._setup_for_bulk_update  s     Y/	## #$$% 
 $$&	+@R@,,=     !% 5 5 ; ; =% =HC99 11  =%D!
 #%s   3C"C"c           
       > UR                  SU R                  5      nUR                  (       a:  UR                  S[        R                  5      nUSS0-  nUR                  SU05      nUR                  S;  a  [        R                  " S5      eUR                  S:X  a  UR                  (       + n	UR                  S:w  d   eUR                  (       a&  UR                  S	:X  a  [        R                  " S
5      eUR                  n
U
c   eUR                  c   e[        U
[        S[!        U["        5      (       a  U/OU5      UR                  SSUU	S9nU R%                  UUUUUU5      $ [&        TU ]Q  UUUUUU5      $ )Nr.  r   r  T)r7  r  rZ   r6  zOValid strategies for ORM UPDATE strategy are 'orm', 'auto', 'bulk', 'core_only'rZ   r:  r9  zbulk synchronize of persistent objects not supported when using bulk update with additional WHERE criteria right now.  add synchronize_session=None execution option to bypass synchronize of persistent objects.r  F)rB   r   r   r   )r   r#  r  r   r  r   r  r=  r?  rw  r  r>  r  r  r   r   r   ra   rN  r  r  )r   r^   r   rN   r:   r  rP   rF  r  r   r?   r   r  s               rE   r  #BulkORMUpdate.orm_execute_statement#  s    +..$c&@&@
 ,,,00&(I(IL 1488L 1 7 7'6! '' 0
 
 &&9  ''61(1(A(A$A!!66'AAA ))"77:E00  $33F%%%''333!. *64 8 8VHf $$$)$-&;F ..!  70! rG   Fr$  c               *   UR                   =(       a    UR                  R                  nU(       d  gU(       a  UR                  $ U(       a  UR                  $ U(       a5  UR                  (       d$  [
        R                  " SUR                   S35      eg)NF	Dialect "z" does not support RETURNING with UPDATE..FROM; for synchronize_session='fetch', please add the additional execution option 'is_update_from=True' to the statement to indicate that a separate SELECT should be used for this backend.T)update_returningr   implicit_returningupdate_executemany_returningupdate_returning_multifromr=  r  r   r   r*  r?   r%  r&  r'  r(  normal_answers           rE   r+  BulkORMUpdate.can_use_returningy  s     $$N););)N)N 	 777 5557#E#E%%GLL> *E E  rG   c                  ^ U(       d  g UR                   nUR                   Vs/ s H  ofR                  PM     nnUR                  nU GH  mUR	                  U4S jU 5       UR
                  5      n	UR                  U	5      n
U
(       d  MD  [        T5      R                  U5      nU
R                  nU
R                  R                  U5      nU H  nX;   d  M
  TU   X'   M     U
R                  R                  R                  U
S U5        U
R                  U[!        U5      5        UR                  U5      R                  U5      nU(       d  GM  U
R#                  X5        GM     g s  snf )Nc              3  .   >#    U  H
  nTU   v   M     g 7fr<   r=   )rK   rj   params     rE   rU   CBulkORMUpdate._do_post_synchronize_bulk_evaluate.<locals>.<genexpr>  s     /wsws   )r  rq   rj   identity_mapidentity_key_from_primary_keyr"  fast_get_stater   
differencera   
unmodifiedr   managerdispatchrefresh_commitrc   _expire_attributes)r   r^   rN   r   rF  r?   proprd  r  identity_keyrL   evaluated_keysrt   to_evaluaterj   	to_expirer  s                   @rE   rM  0BulkORMUpdate._do_post_synchronize_bulk_evaluate  s;    //(.(B(BC(B88(BC++E!??/w/..L !//=E Z227;NJJE**77GK"<!&sEJ # MM""**5$DMM%k!23
 '33E:EEI y((:; 	 Ds   E(c                4   U R                  UUR                  R                  5       5      nU R                  UUUUR                  R
                  S   U VVVV	s/ s H
  u  pgpXgU4PM     sn	nnnUR                  5       UR                  5       5        g s  sn	nnnf )Nr   )rq  r  
all_states#_apply_update_set_values_to_objectsr   compiled_parametersprefetch_colspostfetch_cols)
r   r^   r   r   rF  matched_objectsrk  rL   rt   r  s
             rE   rK  +BulkORMUpdate._do_post_synchronize_evaluate  s     >>  ++-

 	//NN..q1=LM_%9Sc% _M  "!!#	

 Ns   Bc                F   UR                   nUR                  nU(       a<  U R                  X5U5      nU Vs/ s H  n[        U5      UR                  4-   PM     n	nOUR
                  n	U	 Vs/ s H  oSS US   4PM     sn V
Vs/ s H<  u  pUR                  b  XR                  :X  d  M#  UR                  [        U
5      US9PM>     snn
 Vs/ s H#  nXR                  ;   d  M  UR                  U   PM%     nnU(       d  g U R                  UUUUR                  R                  S   U Vs/ s H0  nU[        R                  " U5      [        R                  " U5      4PM2     snUR                  5       UR!                  5       5        g s  snf s  snf s  snn
f s  snf s  snf Nr   )r1  )r  returned_defaults_rowsrf  rr   r"  r!  r	  rc   r  r  r   r  r   instance_stateinstance_dictr  r  )r   r^   r   r   rF  target_mapperr#  pk_rowsre  r  r   r1  r  objsrk  s                  rE   rL  (BulkORMUpdate._do_post_synchronize_fetch  s    '66!'!>!>!33'=G
 #"C c
n<<>>"  L
 *77L 5A44@S2YB(L4
!
4/K "119!%C%CC;;%#1 < 4
!

! 333 /G  .
! 	 
  //NN..q1    C	 --c2,,S1
     "!!#	
54
!
0s)   #F	,F"F+FF%F,7Fc           
        UR                   nUR                  n	[        R                  " U	5      n
U R	                  X5      nU R                  X5      n0 nU H>  u  p U
R                  [        R                  " [        R                  U5      5      nUX'   M@     [        UR                  5       5      nU VVs1 s H  u  nnUiM
     nnn[        5       nU Vs1 s H;  nUR                  U;   d  M  UUR                   ;   d  M'  UR                  U;  d  M9  UiM=     nnU Vs1 s H.  nUUR                   ;   d  M  UR                   U   R                  iM0     snR#                  U5      nU Vs/ s H(  nUR                   U   R                  UR                  4PM*     nnU GH  u  nnnUR%                  U VVs0 s H  u  nnUUU   _M     snn5        UR'                  UR(                  U5        UR*                  R-                  U5      nU H  nUU;   d  M  X   " U5      UU'   M     UR.                  R0                  R3                  USU5        UR5                  U[        U5      5        UR-                  U5      R#                  U5      nU(       a  UR'                  UU5        UR7                  U5        GM     UR9                  U5        g! [        R                   a     GM  f = fs  snnf s  snf s  snf s  snf s  snnf )zUapply values to objects derived from an update statement, e.g.
UPDATE..SET <values>

N)r  r   r   rv  r  r  rz  r   r   r    r   r  rc   r   r   rj   r  r  r  r  ra   r  r   r  r  r  r  add_register_altered) r   r^   rF  r   effective_paramsr  r  r  r?   r{  r|  r  resolved_keys_as_propnamesvalue_evaluatorsrj   value
_evaluatorr  r   r   attribrs   r   to_prefetchr  prefetch_transferrk  rL   rt   col_to_propc_keyr  s                                    rE   r  1BulkORMUpdate._apply_update_set_values_to_objects  s      //]]
&99*E226E%(%D%D&
" 4JC3/77$$U%@%@%H
 )3 % 5 .3356 :; :1! :; #
"uu((  V---  ^+	 " 	 
 $
#F,,, ,F$$Q'++#
 *^
$	 	 ?J
>IV%%a(,,aee4k 	 
 "1CLL /@.?*U  !1%!88.? $$UZZ;**77GK"%<!1!6s!;E#J #
 MM""**5$DMM%k!23
 ++E2==kJI((	:JJu; "1< 	!!&)s //  <


sH   4K5K"K(-K(?K(K(K-5K-(/K23K7KK)r  r  r?   r   )r^   r1   r   z
dml.UpdaterN   r6   r:   r,   r  r/   rP   r4   r  r  r  )r   r	  r
  r  r  r   r  r  r  r+  rM  rK  rL  r  r  r  r  s   @rE   r  r    s?    ,`"D"#H SS S &	S
 6S 'S S 
S Sj  $$ %$"" "
 " " " " 
" "H (; (;T 
 
$ 3
 3
j U* U*rG   r  deletec                     ^  \ rS rSr\S 5       r\              S
U 4S jj5       r\SSSSS.             SS jj5       r\S 5       r\S 5       r	S	r
U =r$ )BulkORMDeleteik  c           	     R   U R                  U 5      nUR                  R                  SS5      nUS:X  d   US:X  a4  SUR                  R                  ;  a  [        R
                  " XAU40 UD6  U$ UR                  (       + nUnUR                  R                  S   nUR                  =Ul        n	UR                  UUUUS9  UR                  5       n
U
R                  R                  S   U	L a  U	R                  U
l        U R                  UR                  U	5      nU(       a  U
R                  " U6 n
[        R
                  " XJU40 UD6  SnU(       d  S nOUR                  R                  SS 5      nUR                  R                  SS 5      nUSLaL  US	:H  =(       a@    UR                  UR                  U	UR                   UR                  R                  S
S5      S9nU(       a%  SnU
R"                  " U
R                  R$                  6 n
U(       a  UR'                  UUU
U	US9n
Xl        U$ )Nr0  r  r6  r   r  Fr3  r+  r:  r'  )r%  r'  Tr  )r  r   r   rw   r&   r  r  r?   r  r  r   r_  r]  r  r+  r*  r%  rC   r   r   r   )r   r   r   r  r   r0  r  r   r   r?   r  r  r   r3  r+  s                  rE   r   "BulkORMDelete.create_for_statementm  s7   {{3 --11M

 K'},ioo&B&BB##DXDDK~~%'??//?'.f$$*2	 	% 	
 ##%>>&&~6&@#//HN11""F
 ~~x0H 	?B? %"&"*"7"7";";%t# %1155
 E) $w. **$$"&"4"4$,$9$9$=$=)5%	 +   $(!//1K1KLH00#!&; 1 H "rG   c                   > UR                  SU R                  5      nUR                  S:X  a  [        R                  " S5      eUR                  S;  a  [        R
                  " S5      e[        TU ]  XX4XV5      $ )Nr.  rZ   zBulk ORM DELETE not supported right now. Statement may be invoked at the Core level using session.connection().execute(stmt, parameters))r7  r  r6  zGValid strategies for ORM DELETE strategy are 'orm', 'auto', 'core_only')r   r#  r  r=  r>  r?  r  r  )	r   r^   r   rN   r:   r  rP   rF  r  s	           rE   r  #BulkORMDelete.orm_execute_statement  s     +..$c&@&@
 ''61,,A  ''/KK&& 
 w,>
 	
rG   Fr$  c                  UR                   =(       a    UR                  R                  nU(       d  gU(       a  UR                  $ U(       a5  UR                  (       d$  [        R
                  " SUR                   S35      eg)NFr  z" does not support RETURNING with DELETE..USING; for synchronize_session='fetch', please add the additional execution option 'is_delete_using=True' to the statement to indicate that a separate SELECT should be used for this backend.T)delete_returningr   r  delete_returning_multifromr=  r  r   r  s           rE   r+  BulkORMDelete.can_use_returning  sz     $$N););)N)N 	   5557#E#E %%GLL> *E E  rG   c                $   U R                  UUR                  R                  5       5      n/ nU HE  u  pxpU
(       a'  UR                  XR                  R                  5        M4  UR                  U5        MG     U(       a  UR                  U5        g g r<   )rq  r  r  _expire	_modifiedrm  _remove_newly_deleted)r   r^   r   r   rF  r  	to_deleter  rL   rt   is_partially_expireds              rE   rK  +BulkORMDelete._do_post_synchronize_evaluate  s     >>  ++-

 	5D1Ae#e%9%9%C%CD  '	 6E )))4 rG   c                   UR                   nUR                  nU(       a<  U R                  X5U5      nU Vs/ s H  n[        U5      UR                  4-   PM     n	nOUR
                  n	U	 Hj  nUSS n
US   nUR                  [        U
5      US9nXR                  ;   d  M7  UR                  [        R                  " UR                  U   5      /5        Ml     g s  snf r!  )r  r#  rf  rr   r"  r!  r	  rc   r  rF  r   r$  )r   r^   r   r   rF  r&  r#  r'  re  r  r   r1  r  s                rE   rL  (BulkORMDelete._do_post_synchronize_fetch&  s     '66!'!>!>!33'=G #"C c
n<<>>"  L
 *77LCa)K WN )FF[!- G L 333--"11#00>  s   #C)r?   r   )r^   r1   r   z
dml.DeleterN   r6   r:   r,   r  r/   rP   r4   r  r  r  )r   r	  r
  r  r  r   r  r+  rK  rL  r  r  r  s   @rE   r:  r:  k  s    Y Yv 

 
 &	

 6
 '
 
 

 
>  $$ %$&& &
 & & & & 
& &P 5 5& $ $rG   r:  )r?   
Mapper[_O]r@   <Union[Iterable[InstanceState[_O]], Iterable[Dict[str, Any]]]rA   r2   rB   r  rC   r  rD   r  r9   Literal[None]r:   $Optional[OrmExecuteOptionsParameter]r  None)r?   rL  r@   rM  rA   r2   rB   r  rC   r  rD   r  r9   Optional[dml.Insert]r:   rO  r  zcursor.CursorResult[Any])r?   rL  r@   rM  rA   r2   rB   r  rC   r  rD   r  r9   rQ  r:   rO  r  z"Optional[cursor.CursorResult[Any]])r?   r  r@   rM  rA   r2   rB   r  r   r  r   rN  r   r  r  rP  )r?   r  r@   rM  rA   r2   rB   r  r   r  r   Optional[dml.Update]r   r  r  z_result.Result[Any])r?   r  r@   rM  rA   r2   rB   r  r   r  r   rR  r   r  r  zOptional[_result.Result[Any]])O__doc__
__future__r   typingr   r   r   r   r   r	   r
   r   r    r   r   r   r   r  r   r   baser   r   r   r   r   r=  r   enginer   r   r   sqlr   r   r   r    r!   r"   sql.baser#   r$   r%   sql.dmlr&   r'   r(   r)   util.typingr*   _typingr+   r,   r-   r?   r.   r^   r/   r0   r1   r2   rL   r3   r4   r5   engine.interfacesr6   objectr7   rF   r   rd   r   r  
plugin_forr  r  r:  r=   rG   rE   <module>ra     s  
 #                  , " 1 !    &       , #  $ $ $  !,33'( +$#9T  
 *->A

J
 ,

 
 
 
 '
 <
 

 

 
 14>A
#
#J
# ,
#
 
# 
# 
# .
# <
# 
# 

#* 15>BUUJU ,U
 U U U .U <U (Up 
 *-"&		J	 ,	
 	 	 '	  	 
	 
	 
 14"&		J	 ,	
 	 	 .	  	 	 
	& 15"&Y%Y%JY% ,Y%
 Y% Y% .Y%  Y% #Y%x%t) tnC
 C
L )@#K @# *@#F )c*& c* *c*L )_& _ *_rG   