
    
 @gG=                     4   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  G d dej                  Z G d dej                  Z G d dej        ej                  ZdS )    N   )engines)fixtures)eq_)requirements)Column)Table   )DateTime)func)Integer)select)sql)String)testing)textc                   |    e Zd ZdZed             Zed             Zd Zd Zd Z	d Z
ej        d             Zd	 Zd
S )RowFetchTestTc                     t          d|t          dt          d          t          dt          d                               t          d|t          dt          d          t          dt                               d S )	Nplain_pkidTprimary_keydata2   	has_datestoday)r	   r   r   r   r   clsmetadatas     Y/var/www/piapp/venv/lib/python3.11/site-packages/sqlalchemy/testing/suite/test_results.pydefine_tableszRowFetchTest.define_tables   s    4d33366"::&&		
 	
 	
 	4d3337H%%		
 	
 	
 	
 	
    c                    |                     | j        j                                        dddddddddg           |                     | j        j                                        dt          j        dd	d
d
dd          dg           d S )N   d1)r   r   r   d2r
   d3        r   )r   r   )executetablesr   insertr   datetime)r   
connections     r!   insert_datazRowFetchTest.insert_data'   s    J&&(($''$''$''	
 	
 	
 	J '')) 1$2r1a H HIIJ	
 	
 	
 	
 	
r#   c                 .   |                     | j        j                                                            | j        j        j        j                                                            }t          |j        d           t          |j	        d           d S Nr%   r&   )
r,   r-   r   r   order_bycr   firstr   r   selfr0   rows      r!   test_via_attrzRowFetchTest.test_via_attr7   sy      K ''))224;3G3I3LMM
 

%'' 	 	CFACHdr#   c                 F   |                     | j        j                                                            | j        j        j        j                                                            }t          |j	        d         d           t          |j	        d         d           d S )Nr   r%   r   r&   )
r,   r-   r   r   r4   r5   r   r6   r   _mappingr7   s      r!   test_via_stringzRowFetchTest.test_via_string?   s      K ''))224;3G3I3LMM
 

%'' 	 	CL"""CL $'''''r#   c                 2   |                     | j        j                                                            | j        j        j        j                                                            }t          |d         d           t          |d         d           d S )Nr   r%   r&   )	r,   r-   r   r   r4   r5   r   r6   r   r7   s      r!   test_via_intzRowFetchTest.test_via_intG   s}      K ''))224;3G3I3LMM
 

%'' 	 	CFACFDr#   c                    |                     | j        j                                                            | j        j        j        j                                                            }t          |j	        | j        j        j        j                 d           t          |j	        | j        j        j        j
                 d           d S r3   )r,   r-   r   r   r4   r5   r   r6   r   r<   r   r7   s      r!   test_via_col_objectz RowFetchTest.test_via_col_objectO   s      K ''))224;3G3I3LMM
 

%'' 	 	CL-/23Q777CL-/45t<<<<<r#   c                    |                     t          | j        j        j        j        | j        j        j        j                            d                                        | j        j        j        j                            }|	                                }t          |                                ddg           t          |d           d S )Nr   )r&   r&   )r,   r   r-   r   r5   r   labelr4   r   r6   r   keys)r8   r0   resultr9   s       r!   test_row_with_dupe_namesz%RowFetchTest.test_row_with_dupe_namesW   s    ##$&+$&+11&99  ht{+-011	
 
 llnnFKKMMFF+,,,Cr#   c                    | j         j        }t          |                    d          j        j                                                  }t          |j        j        |                    d                    }|	                    |          
                                }t          |j        t          j        dddddd                     dS )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)r-   r   r   aliasr5   r   scalar_subqueryr   rC   r,   r6   r   rI   r/   )r8   r0   	datetabless2r9   s         r!   test_row_w_scalar_selectz%RowFetchTest.test_row_w_scalar_selectc   s     K)	9??3'')/00@@BBIKNAGGK$8$899  $$**,,CM8,T1b"aCCDDDDDr#   N)__name__
__module____qualname____backend__classmethodr"   r1   r:   r=   r?   rA   r   %duplicate_names_in_cursor_descriptionrF   rO    r#   r!   r   r      s        K
 
 [
 
 
 [
  ( ( (  = = = 7	 	 87	E E E E Er#   r   c                   b    e Zd ZdZdZdZed             Zd Zd Z	e
j        d             Zd Zd	S )
PercentSchemaNamesTestztests 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           	         t          d|t          dt                    t          dt                              | j        _        t          j        dt          j        d          t          j        d                    | j        _        d S )Nzpercent%tablepercent%spaces % more spaces)	r	   r   r   r-   percent_tabler   tablecolumnlightweight_percent_tabler   s     r!   r"   z$PercentSchemaNamesTest.define_tables   ss    #(:w'')733	$
 $

  03yJz""J-..0
 0

,,,r#   c                     | j         j        }ddddddddddddfD ]*}|                    |                                |           +|                     |           d S Nr*   r+   r[   r\         	   
   r-   r]   r,   r.   _assert_table)r8   r0   r]   paramss       r!   test_single_roundtripz,PercentSchemaNamesTest.test_single_roundtrip   s    1B77B77B77Q77	
 	? 	?F }3355v>>>>:&&&&&r#   c                    | j         j        }|                    |                                ddd           |                    |                                dddddddddg           |                     |           d S rb   rh   )r8   r0   r]   s      r!   test_executemany_roundtripz1PercentSchemaNamesTest.test_executemany_roundtrip   s    1  ""B$O$O	
 	
 	
 	  "";;;;;;	
 	
 	
 	:&&&&&r#   c                    | j         j        }|                    |                                ddd           |                    |                                                    |j        d         |j        d                   ddddd	ddddg          }t          |                                g d
           |                     |           d S )Nr*   r+   rc   r[   r\   rd   re   rf   rg   )rd   re   rf   rg   re   rf   )	r-   r]   r,   r.   	returningr5   r   allri   )r8   r0   r]   rE   s       r!   $test_executemany_returning_roundtripz;PercentSchemaNamesTest.test_executemany_returning_roundtrip   s    1  ""B$O$O	
 	
 	
 ##  "",,
+ 67 
 ;;;;;;

 

 	FJJLL555666:&&&&&r#   c                    | j         j        }| j         j        }||                                ||                                fD ]}t	          t          |                    |                                                    |j	        d                                       g d           t	          t          |                    |                                
                    |j	        d                             ddg                                        |j	        d                                       ddg           |                    |                                                    |j	        d                                                             }t	          |j        d         d           t	          |j        d         d	           t	          |j        |j	        d                  d           t	          |j        |j	        d                  d	           |                    |                                                    |j	        d         d
i                     t	          t          |                    |                                                    |j	        d                                       g d           d S )Nr[   ))r*   r+   ro   rp   rq   r\   rf   rg   rp   rq   r*   r+      ))r*   rv   )rd   rv   )rf   rv   )re   rv   )r-   r]   r`   rJ   r   listr,   r   r4   r5   wherein_r6   r<   updatevalues)r8   connr]   r`   r^   r9   s         r!   ri   z$PercentSchemaNamesTest._assert_table   s   1$(K$I! !!%%++--	
 	C 	CE LL!8!89L!M!MNN  544	   LLuw'=>BBAr7KKLL!%'*"566   '"	 	 	 ,,''
(;<< egg  Z(!,,,34b999UWZ011555UW%;<=rBBBB  ""))!78"= 	
 	
 	
 	!((**33%
3    211		
 		
 		
 		
 		
r#   N)rP   rQ   rR   __doc____requires__rS   rT   r"   rk   rm   r   insert_executemany_returningrt   ri   rV   r#   r!   rX   rX   s   s          -LK
 
 [
	' 	' 	'' ' ' .' ' /.'&4
 4
 4
 4
 4
r#   rX   c                       e Zd ZdZdZd Zd Z ej        ddd e	d          dfdd e
d	          dfd
d e	d          dfdd e
d	                              d          dfdd e
d	                              d          dfdd e
d	                                          dfdddd ej        ddg          fdd e	d          dfdd e	d                              d          dfdd          d             Zd Zd Zd Zd Zd Zd S )!ServerSideCursorsTest)server_side_cursorsTc                    | j         j        j        dk    rt          |j                  S | j         j        j        dk    r)t          d          j        j        }t          ||          S | j         j        j        dv r|j	        S | j         j        j        dk    r)t          d          j        j        }t          ||          S | j         j        j        dk    r|j
         S | j         j        j        dv r|j	        S | j         j        j        d	k    rt          |d
d          S | j         j        j        dk    rt          t          |dd                    S dS )Npsycopg2pymysqlzpymysql.cursors)aiomysqlasyncmyaioodbcmysqldbzMySQLdb.cursorsmariadbconnector)asyncpg	aiosqlitepg8000server_sideFpsycopgname)enginedialectdriverboolr   
__import__cursorsSSCursor
isinstancer   bufferedgetattr)r8   cursorsscursors      r!   _is_server_sidez%ServerSideCursorsTest._is_server_side   sE    ;%33$$$[ '944!"344<EHfh///[ '+MMM%%[ '944!"344<EHfh///[ '+===&&[ '+CCC%%[ '8336=%888[ '944667775r#   c                     |rIt          j        d          5  t          j        d|i          | _        d d d            n# 1 swxY w Y   nt          j        d|i          | _        | j        S )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   )r8   r   s     r!   _fixturezServerSideCursorsTest._fixture  s     	*    &424GH                 "0.0CD  DK {s   A  AA)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mssql
text_no_ssz	select 42text_ss_optioniaaaz*engine_ss_arg, statement, cursor_ss_status)id_argnamesc                    |                      |          }|                                5 }t          |t                    r|                    |          }n|                    |          }t          |                     |j                  |           |	                                 d d d            d S # 1 swxY w Y   d S )N)
r   beginr   strexec_driver_sqlr,   r   r   r   close)r8   engine_ss_arg	statementcursor_ss_statusr   r|   rE   s          r!   test_ss_cursor_statusz+ServerSideCursorsTest.test_ss_cursor_status"  s    N }--\\^^ 	t)S)) 1--i88i00$$V]335EFFFLLNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A=B44B8;B8c                 <   |                      d          }|                                5 }|                    d                              d          }|                     |j                  sJ |                                 d d d            d S # 1 swxY w Y   d S )NFTr   r   )r   connectexecution_optionsr   r   r   r   )r8   r   r|   rE   s       r!   test_conn_optionz&ServerSideCursorsTest.test_conn_optionR  s    u%%^^ 	++# ,  oj))  ''66666 LLNNN'	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   ABBBc                 \   |                      d          }t          d                              d          }|                                5 }|                    d                              |          }|                     |j                  rJ 	 d d d            d S # 1 swxY w Y   d S )NFr%   Tr   )r   r   r   r   r,   r   r   )r8   r   rM   r|   rE   s        r!   &test_stmt_enabled_conn_option_disabledz<ServerSideCursorsTest.test_stmt_enabled_conn_option_disabledj  s    u%%1II''t'<<^^ 	;++5+AAII!LLF++FM::::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   AB!!B%(B%c                    |                      d          }t          t          j        d                              d                                        d                                          }|                                5 }|                    |                                          }| 	                    |j
                  rJ |                                 d d d            n# 1 swxY w Y   t          d                              |          }|                                5 }|                    |          }| 	                    |j
                  rJ |                                 d d d            d S # 1 swxY w Y   d S )NF1rH   Tr   r%   )r   r   r   literal_columnrC   r   subqueryr   r,   r   r   r   select_from)r8   r   s1r|   rE   rN   s         r!   test_aliases_and_ssz)ServerSideCursorsTest.test_aliases_and_sst  s   u%%3%c**005566d33XZZ 	 \\^^ 	t\\"))++..F++FM:::::LLNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 AYY""2&&\\^^ 	t\\"%%F++FM:::::LLNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s&   AC((C,/C,)AE<<F F c                    | j         }|                     d          }t          d|t          dt          d          t          dt          d                              }|                                5 }|                    |d           |                    |	                                t          d	                     |                    |	                                t          d
	                     t          |                    |                                                    |j        j                                                            ddg           |                    |                                                    |j        j        dk                                  |j        j        dz   	                     t          |                    |                                                    |j        j                                                            ddg           |                    |                                           t          |                    t          t/          j        d                                        |                    d           d d d            d S # 1 swxY w Y   d S )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,   r.   dictr   r   r4   r5   r   fetchallrz   rx   r{   r   deletescalarr   countr   )r8   r    mdr   r   r0   s         r!   test_roundtrip_fetchallz-ServerSideCursorsTest.test_roundtrip_fetchall  s   ]t$$4d33366"::&&	
 

 \\^^ 	zjT:::z0022Dg4F4F4FGGGz0022Dg4F4F4FGGG""%%''00AA (**|,	   !!##z|!+,,Z\.;<<  
 ""%%''00AA (**34	   z0022333!!4:c??++77
CC  	  -	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   3H5J55J9<J9c                    | j         }|                     d          }t          d|t          dt          d          t          dt          d                              }|                                5 }|                    |d           |                    |	                                d t          d	d
          D                        |                    |                                                    |j        j                            }t          |                    d          d t          d	d          D                        t          |                    d          d t          dd          D                        t          |                                d t          dd
          D                        d d d            d S # 1 swxY w Y   d S )NTr   r   r   r   r   r   c                 4    g | ]}t          d |z            S )data%dr   )r   .0is     r!   
<listcomp>zBServerSideCursorsTest.test_roundtrip_fetchmany.<locals>.<listcomp>  s'    ???Q8a<(((???r#   r%      r*   c                     g | ]	}|d |z  f
S r   rV   r   s     r!   r   zBServerSideCursorsTest.test_roundtrip_fetchmany.<locals>.<listcomp>  s!    888q!X\"888r#      rg   c                     g | ]	}|d |z  f
S r   rV   r   s     r!   r   zBServerSideCursorsTest.test_roundtrip_fetchmany.<locals>.<listcomp>  s!    999q!X\"999r#      c                     g | ]	}|d |z  f
S r   rV   r   s     r!   r   zBServerSideCursorsTest.test_roundtrip_fetchmany.<locals>.<listcomp>  s!    #M#M#M!Q1$5#M#M#Mr#   )r    r   r	   r   r   r   r   r   r,   r.   ranger   r4   r5   r   r   	fetchmanyr   )r8   r    r   r   r   r0   rE   s          r!   test_roundtrip_fetchmanyz.ServerSideCursorsTest.test_roundtrip_fetchmany  s   ]t$$4d33366"::&&	
 

 \\^^ 	OzjT:::!!##??%2,,???  
  ''!!##,,Z\_== F   ##88E!QKK888     $$99E!RLL999   !!#M#MuR}}#M#M#MNNN'	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	Os   3EGGGN)rP   rQ   rR   r~   rS   r   r   r   combinationsr   r   r   with_for_updateskip_ifr   r   r   r   r   r   rV   r#   r!   r   r      s        ,LK  0  " W1	dd:..5	ffQii.	ttJ'7'7?F1II''t'<<		
 #F1II''u'==		
 
D&&))";";"="=tD  !GOXw/00	
 
udd;//7D//t/DD		
 =E# # #H
 
I# #H
  0; ; ;  (& & &PO O O O Or#   r   )r/    r   r   
assertionsr   configr   schemar   r	   r   r   r   r   r   r   r   r   
TablesTestr   rX   TestBaseAssertsExecutionResultsr   rV   r#   r!   <module>r      s                      ! ! ! ! ! !                                                            [E [E [E [E [E8& [E [E [E||
 |
 |
 |
 |
X0 |
 |
 |
~\O \O \O \O \Ow6\O \O \O \O \Or#   