
    g                        d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddl"m#Z# ddl"m$Z$ dd lm%Z% dd!lm&Z& dd"l'm(Z( er6dd#l)m*Z* dd$l)m+Z+ dd%lm,Z, dd&lm-Z- dd'lm.Z. dd(lm/Z/ dd)lm0Z0 dd*lm1Z1 dd+lm2Z2  e&jf                  d,d-      Z4dRd0Z5ed.e6eee6d1f      e
e6   f   Z7ed2e6e6e
e6   f   Z8ed/e6d1e
e6   f   Z9ee7   Z: G d3 d4e      Z;	 	 	 	 	 	 	 	 	 	 	 	 dSd5Z<e	 	 	 dT	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dUd6       Z=e	 	 	 	 	 	 	 	 	 	 dVd7       Z=	 	 	 dW	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dXd8Z=d9 Z>	 	 	 	 	 	 	 	 dYd:Z?d; Z@d< ZAd= ZBd> ZCd? ZDd@ ZEdA ZF	 	 	 	 	 	 	 	 	 	 	 	 dZdBZGdC ZHe	 d[	 	 	 	 	 	 	 	 	 d\dD       ZIe	 	 	 	 	 	 	 	 	 	 d]dE       ZI	 	 d^	 	 	 	 	 	 	 	 	 	 	 d_dFZIe	 d[	 	 	 	 	 	 	 	 	 d\dG       ZJe	 	 	 	 	 	 	 	 	 	 d]dH       ZJ	 	 d^	 	 	 	 	 	 	 	 	 	 	 d_dIZJ G dJ dKej^                  e         ZK	 	 	 	 	 	 	 	 	 	 	 	 d`dLZLdM ZM	 	 	 	 	 	 	 	 	 	 	 	 	 	 dadNZNdO ZOdP ZPdQ ZQy)bziFunctions used by compiler.py to determine the parameters rendered
within INSERT and UPDATE statements.

    )annotationsN)Any)Callable)cast)Dict)Iterable)List)MutableMapping)
NamedTuple)Optional)overload)Sequence)Set)Tuple)TYPE_CHECKING)Union   )	coercions)dml)elements)roles)_DefaultDescriptionTuple)isinsert)ColumnClause)default_is_clause_element)default_is_sequence)Select)TableClause   )exc)util)Literal)_BindNameForColProtocol)SQLCompiler)_DMLColumnElement)DMLState)
ValuesBase)ColumnElement)KeyedColumnElement)_SQLExprDefault)ColumnREQUIREDa8  
Placeholder for the value within a :class:`.BindParameter`
which is required to be present when the statement is passed
to :meth:`_engine.Connection.execute`.

This symbol is typically used when a :func:`_expression.insert`
or :func:`_expression.update` statement is compiled without parameter
values present.

ColumnElement[Any]ColumnClause[Any]c                V    t        | t              st        j                  d|       | S )Nz5Can't create DML statement against column expression )
isinstancer   r    CompileError)cs    R/var/www/html/AdoubleTech/venv/lib/python3.12/site-packages/sqlalchemy/sql/crud.py_as_dml_columnr4   J   s0    a&CA5I
 	
 H    r*   KeyedColumnElement[Any]c                  L    e Zd ZU ded<   ded<   dZded<   dZded<   d	Zd
ed<   y	)_CrudParams_CrudParamSequencesingle_params$List[Sequence[_CrudParamElementStr]]all_multi_paramsFboolis_default_metavalue_onlyuse_insertmanyvaluesNzOptional[Sequence[Column[Any]]]use_sentinel_columns)__name__
__module____qualname____annotations__r>   r?   r@    r5   r3   r8   r8   j   s0    %%::&+t+!&$&<@9@r5   r8   c                \	   g | _         g | _        g | _        g | _        |j	                  dd      }||j                  dd       d|vsJ d       t        | ||      \  }}|| _        |j                  r!|j                  rt        j                  d      |j                  r!t        | ||d||dd||       t        g g       S | j                  {|j                   rot        |j"                  j$                  D cg c]E  }|j&                  s7|| j(                  j+                  |      t-        | |dd      |j.                  ffG c}g       S t1        |      rP|j2                  rD|j4                  }	|	J |	d	   }
t7        |
j9                               }|
D ch c]
  } |       }}n|j:                  r2|j<                  }
|j:                  }|
J |
D ch c]
  } |       }}nM|j<                  r;|j<                  }
t7        |
j9                               }|
D ch c]
  } |       }}ndx}x}
}| j                  i }nS|r-|J | j                  D ci c]  }||vr |      t>         }}n$| j                  D ci c]  } |      t>         }}g }|tA        | |||||       i }tC        jD                  |      r|jF                  rtI        | ||||||||	       t1        |      r4|jJ                  r(|j2                  rJ tM        | |||||||||       d
}d}ntO        | |||||||||      \  }}|rd|rbtQ        |      jS                  fd|D              jU                  |      }|r.t        j                  ddjW                  d |D              z        d
}t1        |      rJ|j2                  r>|jJ                  rJ tY        | ||t[        d|      t[        d      |      }t        ||      S |s| j\                  r| j^                  j`                  rmtc        |j"                  j$                  d	         | j(                  j+                  |j"                  j$                  d	         | j^                  jd                  dfg}d}t        |g |||      S c c}w c c}w c c}w c c}w c c}w c c}w )aQ  create a set of tuples representing column/string pairs for use
    in an INSERT or UPDATE statement.

    Also generates the Compiled object's postfetch, prefetch, and
    returning column collections, used for default handling and ultimately
    populating the CursorResult's prefetch_cols() and postfetch_cols()
    collections.

    visiting_cteNaccumulate_bind_namesz;Don't know how to handle insert within insert without a CTEzVCan't compile statement that includes returning() and return_defaults() simultaneouslyrE   T)requiredr   Fc              3  4   K   | ]  \  }} |        y wNrE   ).0kv_column_as_keys      r3   	<genexpr>z#_get_crud_params.<locals>.<genexpr>K  s     N1.+Ns   zUnconsumed column names: %s, c              3  "   K   | ]  }| 	 y wrK   rE   )rL   r2   s     r3   rP   z#_get_crud_params.<locals>.<genexpr>Q  s     8QQ[8s   Sequence[_CrudParamElementStr]Callable[..., str])r>   r?   r@   )3	postfetchinsert_prefetchupdate_prefetchimplicit_returninggetpop_key_getters_for_crud_column_get_bind_name_for_col
_returning_return_defaultsr    r1   isdelete_setup_delete_return_defaultsr8   column_keys_no_parameterstablecolumns_omit_from_statementspreparerformat_column_create_bind_paramkey_compile_state_isinsert_has_multi_parameters_multi_parameterslistitems_ordered_values_dict_parametersr,   !_get_stmt_parameter_tuples_paramsr   isupdateis_multitable_get_update_multitable_params_select_names_scan_insert_from_select_cols
_scan_colssetintersection
differencejoin_extend_values_for_multiparamsr   for_executemanydialectsupports_default_metavaluer4   default_metavalue_token)compilerstmtcompile_statetoplevelkwrG   _getattr_col_key_col_bind_namer2   mpspdstmt_parameter_tuplesri   spd_str_key
parametersvaluescheck_columnsr?   r@   checkr>   multi_extended_valuesrO   s                         @r3   _get_crud_paramsr   r   sg   P H!H!H"$H66.$/L
 	&-r)EDE) 	%Xt]C	 '5H#400/
 	

 %	
 2r"" #(D(D ++	 .. %%33A6&xD4HUUH		 
 	
( 	 .//,,~~e $SYY[ 169:s~c*::		&	&,, - = =69:s~c*::		'	',, $SYY[ 169:s~c*::4888k #
	&&&  ++
+% 3)

 
 6>5I5I
.1N3)

 

 ')F()!	
 35M ||M"}'B'B%!
	
 }-$2D2D !6666%	
  %#5?6
22 +
O\N8MNNZ& 	
 ""-998%88: 
 !& 	 .// %%%% >0 %~6
!
 6#899$$77 tzz11!45!!//

0B0B10EF  88	
 %)!
";11 Y	4 ;
 ; ;

s%   6A
RRRRR$:R)c                     y rK   rE   )r   colvalueprocessrI   namer   s          r3   rh   rh     s     r5   c                     y rK   rE   )r   r   r   r   s       r3   rh   rh          r5   c                    ||j                   }t        j                  |||j                  |      }d|_        |r |j
                  | fi |S |S )N)type_rI   T)ri   r   BindParametertype_is_crud_compiler_dispatch)r   r   r   r   rI   r   r   	bindparams           r3   rh   rh     sZ     |ww&&e388hI I+y++H;;;r5   c                ,   d|v }|sK|j                   r?t        |j                  t        j                        r|| j
                  d|j                  f<   |j                  j                  r|j                  |j                        } |j                  | fi |S )NrG   r   )
uniquer0   ri   r   _truncated_labeltruncated_namesr   _isnull_with_binary_element_typer   )r   r   r   r   r   is_ctes         r3   _handle_values_anonymous_paramr     s    ( r!F LLuyy(";";<=A  +uyy!9:zz //9#5##H333r5   c                   t        j                  |      ro|j                  rct        |j                        t	        j
                  t        j                  t        j                        	 	 	 	 dfd}	 	 	 	 dfd}dfd}nIt	        j
                  t        j                  t        j                        }t        j                  d      x}}|||fS )Nri   c                |     |       }t        | d      r&| j                  v r| j                  j                  |fS |S )Nrc   )hasattrrc   r   )ri   str_key_et
c_key_roles     r3   rO   z4_key_getters_for_crud_column.<locals>._column_as_key  s;     !oGsG$c)9		00r5   c                |    | j                   v r"| j                   j                  | j                  fS | j                  S rK   )rc   r   ri   r   r   s    r3   r   z6_key_getters_for_crud_column.<locals>._getattr_col_key  s1     yyC		00wwr5   c                    | j                   v rGt        rt        | j                   t              sJ | j                   j                  d| j
                  S | j
                  S )N_)rc   r   r0   r   r   ri   r   s    r3   r   z4_key_getters_for_crud_column.<locals>._col_bind_name  sF    yyC %cii==="%))..#''::wwr5   )ri   zUnion[ColumnClause[Any], str]returnUnion[str, Tuple[str, str]])r   r.   r   r   )r   r.   r   str)r   rr   _extra_fromsrx   	functoolspartialr   expect_as_keyr   DMLColumnRoleoperator
attrgetter)r   r   r   rO   r   r   r   r   s         @@r3   r[   r[     s     ||M"}'A'A -,,-&&##U%8%8

	.	(		"	(		 #**##U%8%8
 -5,?,?,FF>+^;;r5   c           	        |j                   D cg c]!  }|j                  j                   ||         # }}| j                  d   d   |u sJ |j                  | j                  d   d<   g }|j
                  r`t        |      }|j                  j                  D ]<  }||vs|j                  s|j                  j                  r,|j                  |       > |D ]a  } ||      }||v rD||vr@|j                  |       |j                  || j                  j                  |      d df       St        | ||||
       c |r|j                  |       | j                  d   d   }t!        |t"              s/t%        j&                  ddj)                  d |D               d      |j+                         }t-        |j.                        |D cg c]	  \  }}}}| c}}z   |_        || j                  d   d<   y y c c}w c c}}w )	N
selectableinsert_from_selectrE   z_Can't extend statement for INSERT..FROM SELECT to include additional default-holding column(s) rQ   c              3  <   K   | ]  \  }}}}t        |        y wrK   )repr)rL   r   ri   s      r3   rP   z0_scan_insert_from_select_cols.<locals>.<genexpr>B  s     LLAsAqd3iLs   z~.  Convert the selectable to a subquery() first, or pass include_defaults=False to Insert.from_select() to skip these columns.)ru   rc   r2   stackselect#include_insert_from_select_defaultsrx   rd   defaultis_sentinelappendrZ   rf   rg   &_append_param_insert_select_hasdefaultextendr0   r   r    r1   r{   	_generaterm   _raw_columns)r   r   r   r   r   rO   r   r   r   r   r   r   colsadd_select_colscol_setr   r2   col_keyins_from_selectr   exprs                        r3   rv   rv   
  s    <@;M;MN4DJJLL-.NDN>>"l+t333/3{{HNN2+,68O//d)::%% 	!C 7"KK//C 	!   "1%j WM%ANN7#MM1h//==a@$KL2$?B o&"..,-AB/62""8 IILOLL	  *335'+O,H,H'I&5M
"Q4DM
 (
$ 4Cr/0% G OdM
s   &G7
G<c                   t        | |||	      \  }}}}}}|j                  s|j                  sJ |j                  r|j                  D cg c]
  } ||       }}t	        |      }|D cg c]C  }t        |t              r1||j                  j                  v r|j                  j                  |   E c}|j                  j                  D cg c]  }|j                  |vs| c}z   }n|j                  j                  }t        |      }|r9|j                  s-|j                  j                  }| j                  j                  }nd x}}|j                   rt	        |j                         }n
t	               }| j"                  }|D ]p  } ||      }||v r||vrt%        | |||||||||||||
       n&|r|j&                  r%|r#|rt)        | ||||
       nt+        | ||||
       n|j,                  )|j,                  j.                  r|t1        | |||||
       n|j2                  @|r||v r|j5                  |       n|j&                  s| j6                  j5                  |       nq|r||v r|j5                  |       nY|j&                  rM||j                  j                  ur5|j8                  s)t;        |       n|j                  rt=        | ||||||
       ||v sZ||vs`|j5                  |       s |r5|j?                  |      |jA                  fd|j                   D               ||fS c c}w c c}w c c}w )Nc              3  *   K   | ]
  }|v r|  y wrK   rE   )rL   r2   remaining_supplementals     r3   rP   z_scan_cols.<locals>.<genexpr>  s"      +
** +
s   )!_get_returning_modifiersrr   r   _parameter_orderingrx   r0   r   rc   r2   ri   rd   rj   rk   _autoincrement_columnr~   #insert_null_pk_still_autoincrements_supplemental_returningrX   _append_param_parameterprimary_key!_append_param_insert_pk_returning$_append_param_insert_pk_no_returningr   r   _append_param_insert_hasdefaultserver_defaultr   rU   nullable"_warn_pk_with_no_anticipated_value_append_param_updaterz   r   )r   r   r   r   r   rO   r   r   r   r   r   need_pksrX   implicit_return_defaultspostfetch_lastrowidr?   r@   ri   parameter_orderingordered_keysr2   r   r   autoincrement_colr   supplemental_returningcompiler_implicit_returningr   r   s                               @r3   rw   rw   O  sz   ( 	!4I  !!]%;%;;;((+8+L+L
$'N3
 
 -. *
#s#tzz||(; JJLL
 

B1\(AQB	C zz!!&}5H;; !JJ<<@@ 	, CGF?##!$T%A%A!B!$"*"="=
  i2 #1%j WM%A $"(#!3(  }}
 &
 6 $62 9 $62 & yy,,(43 $+CVR !!- ,5M0M/66q9&&--a0)a3K.K+2215 TZZ===

215## !( ''44'..q1Si2V  "8!B!B'"
 	$** +
11+
 	
& !"677Q

 Cs   L4+AL9L>!L>c                   t        | |||	      ^}}}}|sy |j                  r| j                  j                  |       |j                  rDt        | j                        | j                  j                  fd|j                  D               y y )Nc              3  ,   K   | ]  }|vs|  y wrK   rE   )rL   r2   ir_sets     r3   rP   z0_setup_delete_return_defaults.<locals>.<genexpr>,  s      +
qA+
s   	)r   _return_defaults_columnsrX   r   r   rx   )r   r   r   r   r   rO   r   r   r   r   r   r   r   r   s                @r3   r`   r`     s     ,D$x,(Q#a $$$##**+CD##X001##** +
33+
 	
 $r5   c                   |j                  |      }| j                  j                  ||j                        }t	               }t        j                  |      r{|r7|j                  r+||u r'|	rd| _        n|r| j                  j                  |       t        | ||f|t        u t        |      r|j                  s ||      n
d ||      z  |d|}n|j                  r|rW|j                   K|j                  r?||u r;|r| j                  j                  |       n| j"                  j                  rd| _        t%        | ||ft        |      r|j                  s ||      n
d ||      z  |d|}n | j&                  |j)                         fd|i|}|j*                  r>|r ||v r| j                  j                  |       n| j,                  j                  |       n|j                  r<|r| j                  j                  |       n[| j"                  j                  rEd| _        n=|r ||v r| j                  j                  |       n| j,                  j                  |       |
j                  ||||f       y )N	use_tableTz%s_m0)rI   r   rH   )r   rH   rH   )rZ   rf   rg   include_table_with_column_exprsrx   r   _is_literalr   r   rX   r   rh   r,   rj   rk   _is_bind_parameterr   r~   r   r   
self_grouprr   rU   )r   r   r   r2   r   r   r   rX   r   r   r   r   r   r   r   	col_valueaccumulated_bind_namess                    r3   r   r   1  s}     NN7#E!!//	]BB 0 I (+uU#/&&
 #/3,#++2215"
 h& /}=$:: q! ~a00"8
 
 
	!	!/#&& "++2215!!55/3,.
 /}=$:: q! ~a00"8
 
 !  
"8
 
 !!'A1I,I++2215 ""))!,}}%//66q9%%9937H0)q4L/L++2215 ""))!,
MM1i(>?@r5   c           	     (   |j                   |j                   j                  r| j                  j                  r|j                   j                  r| j                  j
                  sUt               }|j                  || j                  j                  |       | j                  |j                   fd|i||f       | j                  j                  |       y|j                   j                  rt               }|j                  || j                  j                  |       | j                  |j                   j                  j                         fd|i||f       | j                  j                  |       y|j                  || j                  j                  |      t        | |fi ||j                   ff       y||j"                  j$                  u s|j&                  | j                  j                  |       y|j(                  st+        |       yy)zCreate a primary key expression in the INSERT statement where
    we want to populate result.inserted_primary_key and RETURNING
    is available.

    NrH   )r   is_sequencer~   supports_sequencesoptionalsequences_optionalrx   r   rf   rg   r   rX   is_clause_elementargr   "_create_insert_prefetch_bind_paramri   rc   r   r   r   r   )r   r   r2   r   r   r   s         r3   r   r     s    	yy99  22II&&''::365& ))77:(((II2H !
 /	 ''..q1YY((%(U"MM%%33A6$H$$		002.D 
 +	 ''..q1
 MM%%33A66xIbIUUH	 
djj..	.!2B2B2N##**1-ZZ 	+1- r5   c           	     2   |j                   X|j                   j                  r| j                  j                  r,|j                   j                  r| j                  j
                  r||j                  j                  u r| j                  j                  s|j                   ,|j                   j                  r| j                  j                  s"|j                   [| j                  j                  rE|j                  || j                  j                  |      t        | |fi ||j                  ff       y|j                   <|j                  0|j                   s$||j                  j                  urt#        |       y| j                  j                  rd| _        yy)ao  Create a primary key expression in the INSERT statement where
    we want to populate result.inserted_primary_key and we cannot use
    RETURNING.

    Depending on the kind of default here we may create a bound parameter
    in the INSERT statement and pre-execute a default generation function,
    or we may use cursor.lastrowid if supported by the dialect.


    NT)r   r   r~   r   r   r   rc   r   r   "preexecute_autoincrement_sequencesr   rf   rg   r   ri   r   r   r   r   r   r2   r   r   s        r3   r   r     sK    	
		 		%%  33		**#++>> 	
TZZ---   44 II)		-- ((;; II% ((KK 	!!//228QE"E		
 	
		$

TZZ555 	+1-				-	-
 (,$ 
.r5   c           	        |j                   j                  r| j                  j                  r|j                   j                  r| j                  j
                  st               }|j                  || j                  j                  |       | j                  |j                   fd|i||f       |r ||v r| j                  j                  |       y |j                  s| j                  j                  |       y y y y |j                   j                  rt               }|j                  || j                  j                  |       | j                  |j                   j                  j!                         fd|i||f       |r ||v r| j                  j                  |       y |j                  s| j                  j                  |       y y |j                  || j                  j                  |      t#        | |fi ||j$                  ff       y )NrH   )r   r   r~   r   r   r   rx   r   rf   rg   r   rX   r   rU   r   r   r   r   ri   )r   r   r2   r   r   r   r   s          r3   r   r   .  s    	yy..		""(*:*:*M*M/2u"MM%%33A6$H$$		.D 
 +	 (A1I,I++2215]]""))!, ## +N /( 
	$	$!$!!//2   IIMM,,.*@ 
 '		
 $-E(E''..q1%%a(  	!!//228QE"E		
r5   c           	        t        |j                        r| j                  j                  rt|j                  j                  r| j                  j
                  sG|j                  || j                  j                  |      |j                  j                         df       y y y t        |j                        rQ|j                  || j                  j                  |      |j                  j                  j                         df       y |j                  || j                  j                  |      t        | |fddi||j                  ff       y )NrE   r   F)r   r   r~   r   r   r   r   rf   rg   
next_valuer   r   r   r   ri   r  s        r3   r   r   e  s    199%..		""(*:*:*M*MMM%%33A6II((*	 +N / 
#199	-!!//2		((*		
 	!!//22a).24 		
r5   c           	     j   |j                   }|j                  |j                  j                  s|j                  j                  r|j	                  || j
                  j                  ||       | j                  |j                  j                  j                         fi |df       |r ||v r| j                  j	                  |       y | j                  j	                  |       y |j	                  || j
                  j                  ||      t        | |fi ||j                  ff       y |j                  >|r ||v r| j                  j	                  |       y | j                  j	                  |       y |r:|j                  s|j                   s!||v r| j                  j	                  |       y y y y )Nr   rE   )r   onupdater   r   r   rf   rg   r   r   r   rX   rU   "_create_update_prefetch_bind_paramri   server_onupdater   r^   )r   r   r   r2   r   r   r   include_tables           r3   r   r     s    "AAMzzajj&<&<::''MM%%33"/ 4  %H$$QZZ^^%>%>%@GBG
 (A1I,I++2215""))!,MM%%33"/ 4  7xIbIUUH
 
			&#-E(E''..q1%%a( **$2G2G))##**1- * 3H 	!r5   c                     y rK   rE   r   r2   r   r   s       r3   r   r     r   r5   c                     y rK   rE   r  s       r3   r   r          #&r5   c                ^    t        | |d f||d|}| j                  j                  |       |S N)r   r   )rh   rV   r   r   r2   r   r   r   params         r3   r   r     B     !T#*9;E ##A&Lr5   c                     y rK   rE   r  s       r3   r  r    r   r5   c                     y rK   rE   r  s       r3   r  r    r  r5   c                ^    t        | |d f||d|}| j                  j                  |       |S r  )rh   rW   r   r  s         r3   r  r    r  r5   c                  t    e Zd ZdZd Zd Zd Zd Zej                  d	d       Z
ej                  d	d       Zy)
_multiparam_columnTc                    || _         d|j                  |dz   fz  | _        || _        |j                  | _        |j                  | _        y )N%s_m%dr   )indexri   originalr   r   )selfr  r  s      r3   __init__z_multiparam_column.__init__  sA    
x||UQY77 ''MM	r5   c                    t               rK   NotImplementedError)r  otherr   s      r3   comparez_multiparam_column.compare      !##r5   c                    t               rK   r   )r  r   s     r3   _copy_internalsz"_multiparam_column._copy_internals	  r$  r5   c                    t        |t              xr4 |j                  | j                  k(  xr |j                  | j                  k(  S rK   )r0   r  ri   r  )r  r"  s     r3   __eq__z_multiparam_column.__eq__  s<    u01 0		TXX%0$--/	
r5   c                @    t        j                  | j                        S z1used by default.py -> _process_execute_defaults())r   _from_column_defaultr   r  s    r3   _default_description_tuplez-_multiparam_column._default_description_tuple  s     (<<T\\JJr5   c                @    t        j                  | j                        S r*  )r   r+  r  r,  s    r3   _onupdate_description_tuplez._multiparam_column._onupdate_description_tuple  s     (<<T]]KKr5   N)r   r   )rA   rB   rC   _is_multiparam_columnr  r#  r&  r(  r!   memoized_propertyr-  r/  rE   r5   r3   r  r    sT     "$$
 
K K
 
L Lr5   r  c                   |j                   st        j                  d|z        t        |j                         r5 | j                  |j                   j
                  j                         fi |S |j                   j                  r | j                  |j                   fi |S t        ||      }t        |t        j                        sJ t        | |fddi|S )NzINSERT value for column %s is explicitly rendered as a boundparameter in the VALUES clause; a Python-side value or SQL expression is requiredr   T)r   r    r1   r   r   r   r   r   r  r0   r   Insertr   )r   r   r2   r  r   r   s         r3    _process_multiparam_default_bindr4     s     99@BCD
 	

 
#199	-x		 8 8 :AbAA	
		  x		0R00 E*$

+++1c
#'
+-
 	
r5   c	                Z   |xs dD 	
ci c]*  \  }	}
t        j                  t        j                  |	      |
, }}	}
|j                  }t               }|j                  D ]  }|j                  D ]  }	|	|v s|j                  |       |	| ||	      <   ||	   }| j                  |	|      }t        j                  |      r+t        | |	|f|t        u  ||	      d|}|	j                  f}nf|j                  r ||	      }t        | |	|fd|i|}|f}n>| j                   j#                  |	        | j                  |j%                         fi |}d}|j#                  |	|||f         |D ]6  }|j                  D ]#  }	|	|v r	|	j&                  |	j&                  j(                  s|	j&                  j*                  ru|j#                  |	| j                  |	|       | j                  |	j&                  j,                  j%                         fi |df       | j                   j#                  |	       |j#                  |	| j                  |	|      t/        | |	fd ||	      i||	j                  ff       |	j0                  	| j                   j#                  |	       & 9 y c c}
}	w )NrE   r
  )rI   r   r   )r   expectr   r   r   rx   r   r2   addr   r   rh   r,   ri   r   r   rU   r   r   r  r   r   r   r  r	  )r   r   r   r   r   r   r   r   r   r2   r  normalized_paramsr
  affected_tablestr   r   r   cbns                      r3   rt   rt   A  s    .3Au 	,,a0%7 
 "AAMeO'' M 	MA%%##A&56.q12)!,$,,Qm,L	((/.  "'(!2+A. E >?UUH*--(+C: !U148:E /2V*&&--a0,H,,U-=-=-?F2FE-/*q)U4JKL7	MM>  - 	-A%%'

0F0F:://MM$,,Qm,L,H,, !

 9 9 ;?A 	 &&--a0MM$,,Qm,L> (!2@2CGI UUH	 "".""))!,9	--Os   /J'c           
     :   |}|g}|j                   }|J t        |dd        D ]  \  }	}
g }|
j                         D ci c]  \  }} ||      | }
}}|D ]  \  }}}}|j                  |
v ro|j                  }t	        j
                  |
|         r&t        | ||
|   fdd|j                  |	dz   fz  i|}n4 | j                  |
|   j                         fi |}nt        | |||	|      }|j                  ||||f        |j                  |        |S c c}}w )Nr   r   r  )rl   	enumeratern   ri   r   r   rh   r   r   r4  r   )r   r   r   initial_valuesrO   r   values_0r   r   irow	extensionri   rN   r   col_exprr  accumulated_names	new_params                      r3   r|   r|     s^    HF		(	(B>>BqrF# !302	47IIK@&#q~c"A%@@7? 	L3C5"3ww#~gg((S2 2 C! &!a%(88	!
 !I !1 0 0S1D1D1F M" MI<dCB	 c8Y8IJK'	L* 	i 5!8 M3 As   Dc                   |D ]  \  }} ||      }	|	|j                  |	|       #| j                  ||j                        }
t        j                  |      r4 | j                  t        j                  d ||j                        fi |}n^|j                  r1|j                  j                  r|j                  |j                        } | j                  |j                         fi |}|j                  ||
|df        y )Nr6  )r   rE   )
setdefaultr   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   rO   r   r   rM   rN   colkeyrD  s              r3   rq   rq     s     & 01"!!&!,  ''!N!N ( H $$Q'$H$$**4!&&AEG ''AFFNN 33AFF;A$H$$Q\\^:r: MM1h2./=0r5   c                0   | j                   }|xrc t        |      xrV |j                   xrG | j                   xs |j                  xr |j
                  xr |j                   xr |j                   }|xr& |j                  xr |j                  j                  du}|xra |j                  xrS |j                  j                  xr; |j                  xr- | xs |j                  xs |j                  xs |j
                  }|rd}t        |      r|xr |j
                  }|xs |j                  xs |j                   }	|xr, | j                  xr |j"                  xr |	xs |j$                  }
d}|
r|	r|j&                  r| j)                  |j                        }n|j*                  rE|j
                  xr2 |j                  j                  xr |j                  xr |j,                  }d}
d}nW|j.                  rE|j
                  xr2 |j                  j                  xr |j                  xr |j0                  }d}
d}nd}d}
d}|rB|j2                  s t5        |j                  j6                        }nt5        |j2                        }nd}||xs ||||
|fS )zdetermines RETURNING strategy, if any, for the statement.

    This is where it's determined what we need to fetch from the
    INSERT or UPDATE statement after it's invoked.

    NF)r~   rj   _inliner}   insert_executemany_returningr^   r]   rk   r   rc   r   insert_returning_primary_tablerX   _supports_implicit_returningfavor_returning_over_lastrowidr   r?   !use_insertmanyvalues_wo_returning_sort_by_parameter_order_get_sentinel_column_for_tablerr   update_returningr_   delete_returningr   rx   r2   )r   r   r   r   r~   r   r   rX   should_implicit_return_defaultsexplicit_returningr?   r@   r   s                r3   r   r     s    G 	 		4#M2		4		4 ((( P44N9N9N		4 		4 333   	 	9''	9JJ,,D8  	 	
 $$	

 ((;;	
 66	
$ %$N(N(N %22%$$- 2 #}-84#8#8 	( , ,,++ 	  ((,, #Og&O&O 	  $ "--#+#J#J

$  
		!! ),,??)::) ((	 	(  %#			!! ),,??)::) ((	 	(  %#*/'$#&,, (+4::<<'8$'*4+H+H'I$#'  	==  r5   c                    d| j                   j                  d| j                  d| j                   j                  d}t        | j                   j                        dkD  r|dz  }t        j                  |       y )NzColumn '.z6' is marked as a member of the primary key for table 'z', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed.  Primary key columns typically may not store NULL.r   a0   Note that as of SQLAlchemy 1.1, 'autoincrement=True' must be indicated explicitly for composite (e.g. multicolumn) primary keys if AUTO_INCREMENT/SERIAL/IDENTITY behavior is expected for one of the columns in the primary key. CREATE TABLE statements are impacted by this change as well on most backends.)rc   fullnamer   lenr   r!   warn)r2   msgs     r3   r   r   r  sb     77QVVQWW%5%5	7  177!#	
 	IIcNr5   )r2   r-   r   r.   )r   r$   r   r'   r   r&   r   r=   r   r   r   r8   ).FN)r   r$   r   r-   r   r   r   Literal[True]rI   r=   r   Optional[str]r   r   r   r   )
r   r$   r   r-   r   r   r   r   r   r   )TFN)r   r$   r   r-   r   r   r   r=   rI   r=   r   r_  r   r   r   z'Union[str, elements.BindParameter[Any]])r   r$   r   r'   r   r&   r   zTuple[Callable[[Union[str, ColumnClause[Any]]], Union[str, Tuple[str, str]]], Callable[[ColumnClause[Any]], Union[str, Tuple[str, str]]], _BindNameForColProtocol])r   r$   r   r'   r2   r.   r   zList[_CrudParamElementSQLExpr]r   Dict[str, Any]r   None).)
r   r$   r2   r-   r   r^  r   r   r   r   )
r   r$   r2   r-   r   zLiteral[False]r   r   r   zelements.BindParameter[Any])TN)r   r$   r2   r-   r   r=   r   r_  r   r   r   z'Union[elements.BindParameter[Any], str])r   r$   r   r'   r2   r6   r  intr   r`  r   r   )r   r$   r   r'   r   r&   r?  rS   rO   rT   r   r`  r   r;   )R__doc__
__future__r   r   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r    r   r   r   r   baser   r   rj   r   schemar   r   r   r   r   r    r!   util.typingr"   r   r#   r$   r%   r&   r'   r(   r)   r*   r+   symbolr,   r4   r   _CrudParamElement_CrudParamElementStr_CrudParamElementSQLExprr9   r8   r   rh   r   r[   rv   rw   r`   r   r   r   r   r   r   r   r  r  r4  rt   r|   rq   r   r   rE   r5   r3   <module>rn     s   #         !              * 4 " - '  #   !1%&','4;;	 c$$% SM  SM  !SM  +, A* AOO
O O 	O
 O Od 

 !	  	
    	 
 
	  	
 	 
 	  	
    -*#4L3<3<!+3<<D3<3<lBCJA8H
<pAf:.zJ,Z4
n&
&

&
 &
 +	&

 	&
 
&
R+.\ 
 !  	
 	 
 
&&& & 	&
 !& 
& 	  	
  - 
 !  	
 	 
 
&&& & 	&
 !& 
& 	  	
  -!L//4 !LH



 
 	

 	
 	
BO-d))
) ) 3	)
 ') 	) *)X'0TFRr5   