
    -h7                     T   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\R(                  5      r " S S\R(                  5      r " S S\R.                  \R0                  5      rg)    N   )engines)fixtures)eq_)requirements)Column)Table   )DateTime)func)Integer)select)sql)String)testing)text)utilc                   z    \ rS rSrSr\S 5       r\S 5       rS rS r	S r
S r\R                  S	 5       rS
 rSrg)RowFetchTest   Tc                     [        SU[        S[        SS9[        S[        S5      5      5        [        SU[        S[        SS9[        S[        5      5        g )	Nplain_pkidTprimary_keydata2   	has_datestoday)r	   r   r   r   r   clsmetadatas     zC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/testing/suite/test_results.pydefine_tablesRowFetchTest.define_tables   sP    4d366":&		
 	4d37H%		
    c                 &   UR                  U R                  R                  R                  5       SSS.SSS.SSS./5        UR                  U R                  R                  R                  5       S[
        R
                  " SS	S
S
SS5      S./5        g )N   d1)r   r   r   d2r
   d3        r   )r   r   )executetablesr   insertr   datetime)r!   
connections     r#   insert_dataRowFetchTest.insert_data,   s    JJ&&($'$'$'	
 	JJ  '') 1 1$2r1a HIJ	
r&   c                 L   UR                  U R                  R                  R                  5       R	                  U R                  R                  R
                  R                  5      5      R                  5       n[        UR                  S5        [        UR                  S5        g Nr(   r)   )
r/   r0   r   r   order_bycr   firstr   r   selfr3   rows      r#   test_via_attrRowFetchTest.test_via_attr<   sp      KK  '')224;;3G3G3I3I3L3LM

%' 	 	CFFACHHdr&   c                 X   UR                  U R                  R                  R                  5       R	                  U R                  R                  R
                  R                  5      5      R                  5       n[        UR                  S   S5        [        UR                  S   S5        g )Nr   r(   r   r)   )
r/   r0   r   r   r8   r9   r   r:   r   _mappingr;   s      r#   test_via_stringRowFetchTest.test_via_stringD   s{      KK  '')224;;3G3G3I3I3L3LM

%' 	 	CLL"CLL $'r&   c                 0   UR                  U R                  R                  R                  5       R	                  U R                  R                  R
                  R                  5      5      R                  5       n[        US   S5        [        US   S5        g )Nr   r(   r)   )	r/   r0   r   r   r8   r9   r   r:   r   r;   s      r#   test_via_intRowFetchTest.test_via_intL   sp      KK  '')224;;3G3G3I3I3L3LM

%' 	 	CFACFDr&   c                    UR                  U R                  R                  R                  5       R	                  U R                  R                  R
                  R                  5      5      R                  5       n[        UR                  U R                  R                  R
                  R                     S5        [        UR                  U R                  R                  R
                  R                     S5        g r7   )r/   r0   r   r   r8   r9   r   r:   r   rA   r   r;   s      r#   test_via_col_object RowFetchTest.test_via_col_objectT   s      KK  '')224;;3G3G3I3I3L3LM

%' 	 	CLL--//223Q7CLL--//445t<r&   c                    UR                  [        U R                  R                  R                  R
                  U R                  R                  R                  R
                  R                  S5      5      R                  U R                  R                  R                  R                  5      5      nUR                  5       n[        UR                  5       SS/5        [        US5        g )Nr   )r)   r)   )r/   r   r0   r   r9   r   labelr8   r   r:   r   keys)r<   r3   resultr=   s       r#   test_row_with_dupe_names%RowFetchTest.test_row_with_dupe_names\   s    ##$$&&++$$&&++11&9 ht{{++--001	
 llnFKKMFF+,Cr&   c                    U R                   R                  n[        UR                  S5      R                  R
                  5      R                  5       n[        UR                  R                  UR                  S5      5      nUR                  U5      R                  5       n[        UR                  [        R                  " SSSSSS5      5        g)ztest that a scalar select as a column is returned as such
and that type conversion works OK.

(this is half a SQLAlchemy Core test and half to catch database
backends that may have unusual behavior with scalar selects.)

x	somelabelr,   r-   r.   r   N)r0   r   r   aliasr9   r   scalar_subqueryr   rK   r/   r:   r   rR   r2   )r<   r3   	datetabless2r=   s         r#   test_row_w_scalar_select%RowFetchTest.test_row_w_scalar_selecth   s     KK))	9??3'))//0@@BIKKNNAGGK$89  $**,CMM8,,T1b"aCDr&    N)__name__
__module____qualname____firstlineno____backend__classmethodr$   r4   r>   rB   rE   rH   r   %duplicate_names_in_cursor_descriptionrN   rX   __static_attributes__rZ   r&   r#   r   r      sa    K
 
 
 
(= 77	 8	Er&   r   c                   B    \ rS rSrSrSrSr\S 5       rS r	S r
S rS	rg
)PercentSchemaNamesTestx   ztests using percent signs, spaces in table and column names.

This didn't work for PostgreSQL / MySQL drivers for a long time
but is now supported.

)percent_schema_namesTc           	         [        SU[        S[        5      [        S[        5      5      U R                  l        [
        R                  " S[
        R                  " S5      [
        R                  " S5      5      U R                  l        g )Nzpercent%tablepercent%spaces % more spaces)	r	   r   r   r0   percent_tabler   tablecolumnlightweight_percent_tabler    s     r#   r$   $PercentSchemaNamesTest.define_tables   sa    #(:w')73	$


  03yyJJz"JJ-.0


,r&   c                     U R                   R                  nSSS.SSS.SSS.SSS.4 H#  nUR                  UR                  5       U5        M%     U R	                  U5        g Nr-   r.   )rh   ri         	   
   r0   rj   r/   r1   _assert_table)r<   r3   rj   paramss       r#   test_single_roundtrip,PercentSchemaNamesTest.test_single_roundtrip   sh    11B7B7B7Q7	
F }335v>
 	:&r&   c                     U R                   R                  nUR                  UR                  5       SSS.5        UR                  UR                  5       SSS.SSS.SSS./5        U R	                  U5        g rp   ru   )r<   r3   rj   s      r#   test_executemany_roundtrip1PercentSchemaNamesTest.test_executemany_roundtrip   s{    11  "B$O	
 	  ";;;	
 	:&r&   c                    U R                   R                  nU R                   R                  nUUR                  5       UUR                  5       4 GH  n[	        [        UR                  UR                  5       R                  UR                  S   5      5      5      / SQ5        [	        [        UR                  UR                  5       R                  UR                  S   R                  SS/5      5      R                  UR                  S   5      5      5      SS/5        UR                  UR                  5       R                  UR                  S   5      5      R                  5       n[	        UR                  S   S5        [	        UR                  S   S	5        [	        UR                  UR                  S      S5        [	        UR                  UR                  S      S	5        GM     UR                  UR                  5       R                  UR                  S   S
05      5        [	        [        UR                  UR                  5       R                  UR                  S   5      5      5      / SQ5        g )Nrh   ))r-   r.   )rq   rr   rs   rt   rr   rs   ri   rs   rt   r~   r   r-   r.      ))r-   r   )rq   r   )rs   r   )rr   r   )r0   rj   rm   rS   r   listr/   r   r8   r9   wherein_r:   rA   updatevalues)r<   connrj   rm   rk   r=   s         r#   rv   $PercentSchemaNamesTest._assert_table   s   11$(KK$I$I! !%%++-	
E LL!8!89L!MN 5	 LLuww'=>BBAr7KL!%''*"56 '"	 ,,''
(;<eg  Z(!,34b9UWWZ0115UWW%;<=rB?
B 	  "))!78"=	
 	!((*33%
3 2		
r&   rZ   N)r[   r\   r]   r^   __doc____requires__r_   r`   r$   rx   r{   rv   rb   rZ   r&   r#   rd   rd   x   s4     -LK
 
	''4
r&   rd   c                      \ rS rSrSrSrS rS r\R                  " SSS\
" S5      S4S	S\" S
5      S4SS\
" S5      S4SS\" S
5      R                  SS9S4SS\" S
5      R                  SS9S4SS\" S
5      R                  5       S4SSSS\R                  " S5      4SS\
" S5      S4SS\
" S5      R                  SS9S4SSS9S 5       rS rS rS rS rS rS rg!)"ServerSideCursorsTest   )server_side_cursorsTc                 :   U R                   R                  R                  S:X  a  [        UR                  5      $ U R                   R                  R                  S:X  a*  [        S5      R                  R                  n[        X5      $ U R                   R                  R                  S;   a  UR                  $ U R                   R                  R                  S:X  a*  [        S5      R                  R                  n[        X5      $ U R                   R                  R                  S:X  a  UR                  (       + $ U R                   R                  R                  S;   a  UR                  $ U R                   R                  R                  S	:X  a  [        US
S5      $ g)Npsycopg2pymysqlzpymysql.cursors)aiomysqlasyncmymysqldbzMySQLdb.cursorsmariadbconnector)asyncpg	aiosqlitepg8000server_sideF)enginedialectdriverboolname
__import__cursorsSSCursor
isinstancer   bufferedgetattr)r<   cursorsscursors      r#   _is_server_side%ServerSideCursorsTest._is_server_side   s9    ;;%%3$$[[  ''94!"34<<EEHf//[[  ''+BB%%%[[  ''94!"34<<EEHf//[[  ''+==&&[[  ''+CC%%%[[  ''836=%88r&   c                 "   U(       aF  [         R                  " S5         [        R                  " SU0S9U l        S S S 5        U R                  $ [        R                  " SU0S9U l        U R                  $ ! , (       d  f       U R                  $ = f)NzThe create_engine.server_side_cursors parameter is deprecated and will be removed in a future release.  Please use the Connection.execution_options.stream_results parameter.r   )options)r   expect_deprecatedr   testing_enginer   )r<   r   s     r#   _fixtureServerSideCursorsTest._fixture  s    ** &4424GH {{ "00.0CDDK {{  {{s   A55
B)global_stringTselect 1Tglobal_textr   global_exprr(   global_off_explicitFstmt_optionstream_resultsstmt_option_disabledfor_update_exprfor_update_stringzSELECT 1 FOR UPDATEsqlite
text_no_ssz	select 42text_ss_optioniaaaz*engine_ss_arg, statement, cursor_ss_status)id_argnamesc                 h   U R                  U5      nUR                  5        n[        U[        R                  5      (       a  UR                  U5      nOUR                  U5      n[        U R                  UR                  5      U5        UR                  5         S S S 5        g ! , (       d  f       g = f)N)r   beginr   r   string_typesexec_driver_sqlr/   r   r   r   close)r<   engine_ss_arg	statementcursor_ss_statusr   r   rM   s          r#   test_ss_cursor_status+ServerSideCursorsTest.test_ss_cursor_status  s|    N }-\\^t)T%6%677--i8i0$$V]]35EFLLN ^^s   A8B##
B1c                     U R                  S5      nUR                  5        nUR                  SS9R                  S5      nU R	                  UR
                  5      (       d   e S S S 5        g ! , (       d  f       g = f)NFTr   r   )r   connectexecution_optionsr   r   r   )r<   r   r   rM   s       r#   test_conn_option&ServerSideCursorsTest.test_conn_optionB  sj    u%^^++# , oj)  ''6666 s   AA--
A;c                 ,   U R                  S5      n[        S5      R                  SS9nUR                  5        nUR                  SS9R	                  U5      nU R                  UR                  5      (       a   e S S S 5        g ! , (       d  f       g = f)NFr(   Tr   )r   r   r   r   r/   r   r   )r<   r   rV   r   rM   s        r#   &test_stmt_enabled_conn_option_disabled<ServerSideCursorsTest.test_stmt_enabled_conn_option_disabledL  s{    u%1I''t'<^^++5+AII!LF++FMM::::: s   AB
Bc                    U R                  S5      n[        [        R                  " S5      R	                  S5      5      R                  SS9R                  5       nUR                  5        nUR                  UR                  5       5      nU R                  UR                  5      (       a   eUR                  5         S S S 5        [        S5      R                  U5      nUR                  5        nUR                  U5      nU R                  UR                  5      (       a   eUR                  5         S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NF1rQ   Tr   r(   )r   r   r   literal_columnrK   r   subqueryr   r/   r   r   r   select_from)r<   r   s1r   rM   rW   s         r#   test_aliases_and_ss)ServerSideCursorsTest.test_aliases_and_ssV  s    u%3%%c*0056d3XZ 	 \\^t\\"))+.F++FMM::::LLN 
 AY""2&\\^t\\"%F++FMM::::LLN ^ ^ ^s   +AD</AE<
E

Ec                    U R                   nU R                  S5      n[        SU[        S[        SS9[        S[        S5      5      5      nUR                  5        nUR                  USS9  UR                  UR                  5       [        SS	95        UR                  UR                  5       [        S
S	95        [        UR                  UR                  5       R                  UR                  R                  5      5      R!                  5       SS/5        UR                  UR#                  5       R%                  UR                  R                  S:H  5      R'                  UR                  R(                  S-   S	95        [        UR                  UR                  5       R                  UR                  R                  5      5      R!                  5       SS/5        UR                  UR+                  5       5        [        UR-                  [        [.        R0                  " S5      5      R3                  U5      5      S5        S S S 5        g ! , (       d  f       g = f)NT
test_tabler   r   r   r   
checkfirstdata1r   data2)r(   r   )r   r   r   z updated)r   zdata2 updated*r   )r"   r   r	   r   r   r   r   creater/   r1   dictr   r   r8   r9   r   fetchallr   r   r   r   deletescalarr   countr   )r<   r"   mdr   r   r3   s         r#   test_roundtrip_fetchall-ServerSideCursorsTest.test_roundtrip_fetchallj  s   ]]t$4d366":&	

 \\^zjT:z002Dg4FGz002Dg4FG""%%'00A(*|,	 !!#z||!+,Z\\..;<
 ""%%'00A(*34	 z0023!!4::c?+77
C 	- ^^s   G&I
Ic                    U R                   nU R                  S5      n[        SU[        S[        SS9[        S[        S5      5      5      nUR                  5        nUR                  USS9  UR                  UR                  5       [        SS	5       Vs/ s H  n[        S
U-  S9PM     sn5        UR                  UR                  5       R                  UR                  R                  5      5      n[!        UR#                  S5      [        SS5       Vs/ s H	  ofS
U-  4PM     sn5        [!        UR#                  S5      [        SS5       Vs/ s H	  ofS
U-  4PM     sn5        [!        UR%                  5       [        SS	5       Vs/ s H	  ofS
U-  4PM     sn5        S S S 5        g s  snf s  snf s  snf s  snf ! , (       d  f       g = f)NTr   r   r   r   r   r   r(      zdata%dr   r-      rt      )r"   r   r	   r   r   r   r   r   r/   r1   ranger   r   r8   r9   r   r   	fetchmanyr   )r<   r"   r   r   r   r3   irM   s           r#   test_roundtrip_fetchmany.ServerSideCursorsTest.test_roundtrip_fetchmany  s   ]]t$4d366":&	

 \\^zjT:!!#272,?,Q8a<(,?
  ''!!#,,Z\\__=F   #,1!QK8KqX\"K8   $,1!RL9LqX\"L9 !uR}#M}!1$5}#MN' ^ @ 9 :#M' ^sC   9F>F*+A,F>F/'*F>F4!)F>
F9F>*F>>
G)r   N)r[   r\   r]   r^   r   r_   r   r   r   combinationsr   r   r   with_for_updateskip_ifr   r   r   r   r   r   rb   rZ   r&   r#   r   r      sL    ,LK," 1	d:.5	fQi.	tJ'7?1I''t'<		
 #1I''u'=		
 
D&)";";"=tD  !OOH%	
 
ud;/7//t/D		
 =E#H
I#H
7;(&POr&   r   )r2    r   r   
assertionsr   configr   schemar   r	   r   r   r   r   r   r   r   r   r   
TablesTestr   rd   TestBaseAssertsExecutionResultsr   rZ   r&   r#   <module>r      s        !           [E8&& [E|h
X00 h
VMOw66MOr&   