
    5hI                     r   S SK Jr  S SK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\R4                  5      r " S S\R4                  5      r " S S\R4                  5      rSrg)    )DecimalN   )testing   )fixtures)eq_)requirements)Column)Table   )Double)Float)Identity)Integer)literal)literal_column)Numeric)select)String)LargeBinary)UUID)Uuidc                   f    \ rS rSrSrSrSr\S 5       rS r	S r
S r\R                  S	 5       rS
rg)LastrowidTest    eachT)implements_get_lastrowidautoincrement_insertc                     [        SU[        S[        SSS9[        S[        S5      5      SS9  [        S	U[        S[        SSS
9[        S[        S5      5      SS9  g )N
autoinc_pkidTprimary_keytest_needs_autoincrementdata2   Fimplicit_returning	manual_pkr#   autoincrementr   r
   r   r   clsmetadatas     o/var/www/html/cementerio_25MayoBackend/env/lib/python3.13/site-packages/sqlalchemy/testing/suite/test_insert.pydefine_tablesLastrowidTest.define_tables'   sc    g4$ 66":&$	
 	4d%H66":&$	
    c                     UR                  UR                  5       5      R                  5       n[        UUR                  R
                  S45        g N	some dataexecuter   firstr   dialectdefault_sequence_baseselftableconnrows       r0   _assert_round_trip LastrowidTest._assert_round_trip;   ?    ll5<<>*00222	
r3   c                     UR                  U R                  R                  R                  5       [	        SS95        U R                  U R                  R                  U5        g Nr6   r%   r8   tablesr    insertdictrA   r=   
connections     r0   test_autoincrement_on_insert*LastrowidTest.test_autoincrement_on_insertE   I    KK""))+T{-C	
 	 6 6
Cr3   c                 ,   UR                  U R                  R                  R                  5       [	        SS95      nUR                  [        U R                  R                  R                  R                  5      5      n[        UR                  U45        g rE   r8   rH   r    rI   rJ   scalarr   cr!   r   inserted_primary_keyr=   rL   rpks       r0   test_last_inserted_id#LastrowidTest.test_last_inserted_idK   n    KK""))+T{-C
 vdkk&<&<&>&>&A&ABCA""RE*r3   c                 ,   UR                  U R                  R                  R                  5       [	        SS95      nUR
                  nUR                  [        U R                  R                  R                  R                  5      5      n[        X45        g rE   )r8   rH   r    rI   rJ   	lastrowidrR   r   rS   r!   r   )r=   rL   rV   r\   rW   s        r0   test_native_lastrowid_autoinc+LastrowidTest.test_native_lastrowid_autoincR   sm    KK""))+T{-C
 KK	vdkk&<&<&>&>&A&ABCIr3    N)__name__
__module____qualname____firstlineno__run_deletes__backend____requires__classmethodr1   rA   rM   rX   r	   dbapi_lastrowidr]   __static_attributes__r_   r3   r0   r   r       sM    KKEL
 
&
D+ !! "r3   r   c                      \ rS rSrSrSr\S 5       r\R                  " SSS/5      \R                  " SSS	/5      S
 5       5       r
\R                  S 5       r\R                  S 5       r\R                   S 5       r\R$                  S 5       r\R(                  S 5       r\R(                  S 5       r\R(                  S 5       r\R(                  S 5       rSrg)InsertBehaviorTest\   r   Tc                    [        SU[        S[        SSS9[        S[        S5      5      5        [        SU[        S[        SSS	9[        S[        S5      5      5        [        S
U[        S[        SSS9[        S[        S5      5      SS9  [        SU[        S[        SSS9[        S[        S5      5      [        S[        SS9[        S[        [	        S[        S9[        S5      -   S95        g )Nr    r!   Tr"   r%   r&   r)   Fr*   no_implicit_returningr'   includes_defaultsx   )defaulty2)type_r   )r   r
   r   r   r   r   r-   s     r0   r1    InsertBehaviorTest.define_tables`   s    g4$ 66":&	
 	4d%H66":&		
 	#g4$ 66":&$	
 	g4$ 66":&3+&s':WQZG	
r3   styleplainreturn_defaultsexecutemanyFc                    U R                   R                  nUR                  5       nUR                  (       a  UR                  5       nU(       a  SS0SS0SS0SS0SS0/nOSS0nUR	                  XV5      nUR
                  (       a   eg)z-test another INSERT issue found during #10453r%   d1d2d3d4d5N)rH   rn   rI   ry   r8   returns_rows)r=   rL   rw   rz   r>   stmtr%   rV   s           r0   (test_no_results_for_non_returning_insert;InsertBehaviorTest.test_no_results_for_non_returning_insert   s     11||~  '')DD D>Dt*>>!!>r3   c                 6   UR                  U R                  R                  R                  5       [	        SS95      nUR
                  (       d   eUR                  (       a   eUR                  (       d   eUR                  (       a  UR                  5       b   eg g rE   )
r8   rH   r    rI   rJ   _soft_closedclosed	is_insertr   fetchoner=   rL   rV   s      r0   test_autoclose_on_insert+InsertBehaviorTest.test_autoclose_on_insert   st    KK""))+T{-C
 ~~~88|{{{ >>QZZ\%999%9>r3   c                    UR                  U R                  R                  R                  5       R	                  5       [        SS95      nUR                  (       d   eUR                  (       a   eUR                  (       d   eUR                  (       d   e[        UR                  5       S 5        [        UR                  5       S/5        g )Nr6   rF   r!   )r8   rH   r    rI   ry   rJ   r   r   r   r   r   r   keysr   s      r0   +test_autoclose_on_insert_implicit_returning>InsertBehaviorTest.test_autoclose_on_insert_implicit_returning   s     KK""))+;;=k"
 ~~~88|{{{ ~~~ 	AJJL$ 	AFFHtfr3   c                    UR                  U R                  R                  R                  5       5      nUR                  (       d   eUR
                  (       a   eUR                  U R                  R                  R                  5       R                  U R                  R                  R                  R                  S :g  5      5      n[        [        UR                  5       5      S5        g )Nr   r8   rH   r    rI   r   r   r   whererS   r!   r   lenallr   s      r0   test_empty_insert$InsertBehaviorTest.test_empty_insert   s    t{{55<<>?~~~88|KK""))+11&&((++t3

 	CL!r3   c                    UR                  U R                  R                  R                  5       0 0 0 /5      nUR                  (       d   eUR
                  (       a   eUR                  U R                  R                  R                  5       R                  U R                  R                  R                  R                  S :g  5      5      n[        [        UR                  5       5      S5        g )Nr   r   r   s      r0   test_empty_insert_multiple-InsertBehaviorTest.test_empty_insert_multiple   s    t{{55<<>RM~~~88|KK""))+11&&((++t3
 	CL!r3   c                    U R                   R                  nU R                   R                  nUR                  UR	                  5       [        SSS9[        SSS9[        SSS9/5        UR                  UR	                  5       R                  S[        UR                  R                  5      R                  UR                  R                  R                  SS/5      5      5      5      n[        UR                  S	5        UR                  [        UR                  R                  5      R                  UR                  R                  5      5      n[        UR                  5       S
S/5        g )Nr   data1r!   r%   r   data2r   data3rF   Nr   r   )rH   r)   r    r8   rI   rJ   from_selectr   rS   r%   r   in_r   rT   order_byfetchallr=   rL   	src_table
dest_tableresults        r0   test_insert_from_select_autoinc2InsertBehaviorTest.test_insert_from_select_autoinc   s$   KK))	[[++
(((	
 ##++y{{''(..KK$$(('7);<
 	F''1##:<<$$%..z||/@/@A
 	FOO
J78r3   c                 ^   U R                   R                  nU R                   R                  nUR                  UR	                  5       R                  S[        UR                  R                  5      R                  UR                  R                  R                  SS/5      5      5      5      n[        UR                  S5        UR                  [        UR                  R                  5      R                  UR                  R                  5      5      n[        UR                  5       / 5        g )NrF   r   r   r   )rH   r)   r    r8   rI   r   r   rS   r%   r   r   r   rT   r   r   r   s        r0   'test_insert_from_select_autoinc_no_rows:InsertBehaviorTest.test_insert_from_select_autoinc_no_rows  s    KK))	[[++
##++y{{''(..KK$$(('7);<
 	F''1##:<<$$%..z||/@/@A
 	FOOr"r3   c                    U R                   R                  nUR                  UR                  5       [	        SSS9[	        SSS9[	        SSS9/5        UR                  UR                  5       R                  5       R                  S[        UR                  R                  S-   UR                  R                  5      R                  UR                  R                  R                  SS/5      5      5      5        [        UR                  [        UR                  R                  5      R                  UR                  R                  5      5      R                  5       / S	Q5        g )
Nr   r   r   r   r   r   r   rq   ))r   r   r   r   r   )rH   r)   r8   rI   rJ   inliner   r   rS   r!   r%   r   r   r   r   r   r=   rL   r>   s      r0   test_insert_from_select*InsertBehaviorTest.test_insert_from_select  s   %%LLN(((	
 	LLNVX[uwwzzA~uww||4::GGLL$$gw%78		
 	uww||$--eggll;hjH		
r3   c                    U R                   R                  nUR                  UR                  5       [	        SSS9[	        SSS9[	        SSS9/5        UR                  UR                  5       R                  5       R                  S[        UR                  R                  S-   UR                  R                  5      R                  UR                  R                  R                  SS/5      5      5      5        [        UR                  [        U5      R                  UR                  R                  UR                  R                  5      5      R                  5       / S	Q5        g )
Nr   r   r   r   r   r   r   rq   ))r   r   rq      )r   r   rq   r   )   r   rq   r   )r   r   rq   r   )   r   rq   r   )rH   ro   r8   rI   rJ   r   r   r   rS   r!   r%   r   r   r   r   r   r   s      r0   %test_insert_from_select_with_defaults8InsertBehaviorTest.test_insert_from_select_with_defaults:  s   --LLN(((	
 	LLNVX[uwwzzA~uww||4::GGLL$$gw%78		
 	u&&uww||UWWZZ@hj		
r3   r_   N)r`   ra   rb   rc   rd   re   rg   r1   r   	variationr   r	   r   r   insert_returningr   empty_insertsr   empty_inserts_executemanyr   insert_from_selectr   r   r   r   ri   r_   r3   r0   rk   rk   \   s/   KK%
 %
N w*; <=}tUm4" 5 >"2 &&: ': "" #6 
  
 ++ , $$9 %98 $$# %#( $$
 %
: $$!
 %!
r3   rk   c                      \ rS rSrSrSrSrS r\S 5       r	\
R                  S 5       rS rS	 rS
 r\
R                   S 5       r\R&                  " \" 5       SS4\" S5      SS\R*                  R,                  4\" 5       SS4\" S5      SS\R*                  R,                  4\" SSSS9SS\R*                  R2                  4\" SSSS9\" S5      S4SS9\R6                  " SSS/5      \R6                  " SSS/5      S 5       5       5       r\R&                  " S\" SS9\R>                  " 5       4S\" SSS9\ " \R>                  " 5       5      4S\" SS9\R>                  " 5       \R*                  RB                  4S\" SSS9\ " \R>                  " 5       5      \R*                  RB                  4S \"" 5       \R>                  " 5       \R*                  RB                  4S!\#" 5       S"4S#\#" 5       S$4S%S&S'9	\R6                  " SSS/5      \R6                  " SSS/5      \R*                  RH                  S( 5       5       5       5       r%S)r&g*)+ReturningTesti_  r   )r   r   Tc                     UR                  UR                  5       5      R                  5       n[        UUR                  R
                  S45        g r5   r7   r<   s       r0   rA    ReturningTest._assert_round_tripd  rC   r3   c                 b    [        SU[        S[        SSS9[        S[        S5      5      5        g )Nr    r!   Tr"   r%   r&   r,   r-   s     r0   r1   ReturningTest.define_tablesn  s1    g4$ 66":&	
r3   c                 \   U R                   R                  nUR                  UR                  5       R	                  UR
                  R                  5      [        SS95      nUR                  5       S   nUR                  [        UR
                  R                  5      5      n[        XT5        g Nr6   rF   r   rH   r    r8   rI   	returningrS   r!   rJ   r9   rR   r   r   r=   rL   r>   rV   rW   
fetched_pks         r0   %test_explicit_returning_pk_autocommit3ReturningTest.test_explicit_returning_pk_autocommity  sz    &&LLN$$UWWZZ0$K2H
 WWYq\&&veggjj'9:
Jr3   c                 \   U R                   R                  nUR                  UR                  5       R	                  UR
                  R                  5      [        SS95      nUR                  5       S   nUR                  [        UR
                  R                  5      5      n[        XT5        g r   r   r   s         r0   (test_explicit_returning_pk_no_autocommit6ReturningTest.test_explicit_returning_pk_no_autocommit  sz    &&LLN$$UWWZZ0$K2H
 WWYq\&&veggjj'9:
Jr3   c                     UR                  U R                  R                  R                  5       [	        SS95        U R                  U R                  R                  U5        g rE   rG   rK   s     r0   /test_autoincrement_on_insert_implicit_returning=ReturningTest.test_autoincrement_on_insert_implicit_returning  rO   r3   c                 ,   UR                  U R                  R                  R                  5       [	        SS95      nUR                  [        U R                  R                  R                  R                  5      5      n[        UR                  U45        g rE   rQ   rU   s       r0   (test_last_inserted_id_implicit_returning6ReturningTest.test_last_inserted_id_implicit_returning  rZ   r3   c           	         UR                  U R                  R                  R                  5       R	                  U R                  R                  R
                  R                  5      SS0SS0SS0SS0SS0/5      nUR                  5       nUR                  [        U R                  R                  R
                  R                  5      5      n[        X4R                  5       5        g )Nr%   r|   r}   r~   r   r   )
r8   rH   r    rI   r   rS   r!   r   r   r   )r=   rL   rV   rallpkss        r0   test_insertmanyvalues_returning-ReturningTest.test_insertmanyvalues_returning  s    KK""))+55&&((++ 	
 uuw  (>(>(@(@(C(C!DED'')r3   gxXM|Z!@5   g_Q!@r         F)	precisionscale	asdecimalz	8.5514716ztype_,value,do_rounding)argnamessort_by_parameter_ordermultiple_rowsc                 *   [        SU[        S[        [        5       SS9[        SU5      5      nUR	                  U5        UR                  UR                  5       R                  UR                  R                  UR                  R                  [        U5      S9U(       a  [        S5       V	s/ sH  n	SU0PM	     sn	OSU05      n
U(       a  [        SS	5      nO[        SS
5      nU(       a  [        U
 VVs1 sH  u  pU[        US5      4iM     snnU Vs1 sH  o[        US5      4iM     sn5        [        UR                  [!        UR                  R                  5      5       Vs1 sH  n[        US5      iM     sn[        US5      15        g[        [#        U
5      U Vs1 sH  oU4iM     sn5        [        [#        UR                  [!        UR                  R                  5      5      5      U15        gs  sn	f s  snnf s  snf s  snf s  snf )z^test #9701.

this tests insertmanyvalues as well as decimal / floating point
RETURNING types

f_tr!   Tr#   valuer   
   r      r   rq   N)r   r
   r   r   creater8   rI   r   rS   r!   r   boolranger   roundscalarsr   set)r=   rL   r/   r   ru   r   do_roundingr   tir   i_rangeid_val_s                 r0   test_insert_w_floats"ReturningTest.test_insert_w_floats  s   ^  4(*$?7E"
 	
##HHJ  		(,-D(E !  ! ,1959a'5!95u%
 ArlGAqkG 8>?93#uT1~&?3:;7CuUA'7;
  !+ 2 26!##))3D E E $N E ua! F)01#u1
 J&&vaccii'89:M 6* @; 2s   .G;
7H 
H
)H%H
non_native_uuid)native_uuidnon_native_uuid_str)as_uuidr   generic_native_uuidgeneric_native_uuid_strr   LargeBinary1s   this is binaryLargeBinary2s   7ztype_,valueiaa)r   r   c                    [        SU[        S[        [        5       SS9[        SU5      5      nUR	                  U5        UR                  UR                  5       R                  UR                  R                  UR                  R                  [        U5      S9U(       a  [        S5       Vs/ sH  nSU0PM	     snOSU05      n	U(       a  [        SS	5      n
O[        SS
5      n
[        [        U	5      U
 Vs1 sH  oU4iM     sn5        [        [        UR                  [!        UR                  R                  5      5      5      U15        gs  snf s  snf )ztest #9739, #9808 (similar to #9701).

this tests insertmanyvalues in conjunction with various datatypes.

These tests are particularly for the asyncpg driver which needs
most types to be explicitly cast for the new IMV format

d_tr!   Tr   r   r   r   r   r   r   N)r   r
   r   r   r   r8   rI   r   rS   r!   r   r   r   r   r   r   r   )r=   rL   r/   r   ru   r   r   r   r   r   r   r   s               r0   test_imv_returning_datatypes*ReturningTest.test_imv_returning_datatypes  s&   j 4(*$?7E"	
 	
##HHJ  		(,-D(E !  ! ,1959a'5!95u%
 ArlGAqkGK%,-Wc5\W-	

 	
""6!##))#456G	
! 6 .s   .E
9E
r_   N)'r`   ra   rb   rc   run_create_tablesrf   re   rA   rg   r1   r	   fetch_rows_post_commitr   r   r   r   insert_executemany_returningr   r   combinationsr   requires-float_or_double_precision_behaves_genericallyr   r   literal_float_coercionr   r   r   r   uuiduuid4struuid_data_typer   r   r   r  ri   r_   r3   r0   r   r   _  s   =LK
 
 
 (( )D+ .. /& 	9d#2JJJ		
 
&$!HJJ		
 be<33		
 bd;K 	

 +58 04-@u6M 7 A9<M^ U#JJL	
 "E2

	
 "T"JJL++		
 &D1

++		
 
w'7'7'F'FGM	

 
5? B 04-@u6&&4
 ' 7 AC H4
r3   r   )r   rk   r   )decimalr   r   r   r   
assertionsr   configr	   schemar
   r   r   r   r   r   r   r   r   r   r   typesr   r   r   
TablesTestr   rk   r   __all__r_   r3   r0   <module>r     s         !               9H'' 9x@
,, @
FT
H'' T
n Cr3   