
    [h_                     p   d dl m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$ 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/                  Z0 G d- d.ej,                  Z1 G d/ d0ej,                  Z2 G d1 d2ej,                  Z3 G d3 d4ej,                  Z4 G d5 d6eeej,                  Z5 G d7 d8ej,                  Z6 G d9 d:ej,                  Z7 G d; d<ej,                  Z8 G d= d>ej,                  Z9 G d? d@ej,                  Z: G dA dBej,                  Z; G dC dDeej,                  Z< G dE dFej,                  Z= G dG dHej,                  Z> G dI dJej,                  Z?dS )K    N   )AssertsCompiledSQL)AssertsExecutionResults)config)fixtures)assert_raises)eq_)in_)	CursorSQL)Column)Table   )	bindparam)case)column)Computed)exists)false)
ForeignKey)func)Identity)Integer)literal)literal_column)null)select)String)table)testing)text)true)tuple_)	TupleType)union)values)DatabaseError)ProgrammingErrorc                   n    e Zd ZdZed             Zed             Zd Zej	        j
        d             ZdS )CollateTestTc                     t          d|t          dt          d          t          dt          d                               d S )N
some_tableidTprimary_keydatad   r   r   r   r   clsmetadatas     s/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/testing/suite/test_select.pydefine_tableszCollateTest.define_tables4   sI    4d33366#;;''		
 	
 	
 	
 	
    c                 z    |                     | j        j                                        ddddddg           d S )N   collate data1r,   r/   r   collate data2executetablesr+   insertr3   
connections     r5   insert_datazCollateTest.insert_data=   sS    J!((**/22/22	
 	
 	
 	
 	
r7   c                     t           j                                        5 }t          |                    |                                          |           d d d            d S # 1 swxY w Y   d S Nr   dbconnectr	   r>   fetchallselfr   resultconns       r5   _assert_resultzCollateTest._assert_resultG       Y   	9DV$$--//888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9   6A""A&)A&c                 N   t           j                            t           j                  }|                     t          | j        j                                      | j        j        j	        j
                            |                                                    ddg           d S )N)r9   r:   )r   r<   )r   requiresget_order_by_collationr   rN   r   r?   r+   order_bycr/   collateasc)rK   	collations     r5   test_collate_order_byz!CollateTest.test_collate_order_byK   s    $;;GNKK	4;)**33&(-55i@@DDFF  "#78		
 	
 	
 	
 	
r7   N)__name__
__module____qualname____backend__classmethodr6   rC   rN   r   rR   order_by_collationrY    r7   r5   r)   r)   1   s~        K
 
 [
 
 
 [
9 9 9 (
 
 )(
 
 
r7   r)   c                       e Zd ZdZdZed             Zed             Zd Zd Z	d Z
d Zd	 Zd
 Zej        j        d             ZdS )OrderByLabelTestzTest the dialect sends appropriate ORDER BY expressions when
    labels are used.

    This essentially exercises the "supports_simple_order_by_label"
    setting.

    Tc                    t          d|t          dt          d          t          dt                    t          dt                    t          dt          d                    t          d	t          d                               d S )
Nr+   r,   Tr-   xyq2   pr1   r2   s     r5   r6   zOrderByLabelTest.define_tablesb   sv    4d3333  3  3r

##3r

##	
 	
 	
 	
 	
r7   c                     |                     | j        j                                        ddddddddddddddd	d
ddg           d S )Nr9   r   q1p3)r,   rd   re   rf   rh   r   q2p2   q3p1r=   rA   s     r5   rC   zOrderByLabelTest.insert_datan   sp    J!((**qqt$??qqt$??qqt$??	
 	
 	
 	
 	
r7   c                     t           j                                        5 }t          |                    |                                          |           d d d            d S # 1 swxY w Y   d S rE   rF   rJ   s       r5   rN   zOrderByLabelTest._assert_resulty   rO   rP   c                     | j         j        }|j        j                            d          }|                     t          |                              |          g d           d S )Nlxr9   r   r   )r?   r+   rU   rd   labelrN   r   rT   rK   r   rs   s      r5   
test_plainzOrderByLabelTest.test_plain}   sX    &WY__T""F2JJ//335G5G5GHHHHHr7   c                     | j         j        }|j        j        |j        j        z                       d          }|                     t          |                              |          g d           d S )Nrs   )rw         )	r?   r+   rU   rd   re   rx   rN   r   rT   ry   s      r5   test_composed_intz"OrderByLabelTest.test_composed_int   sc    &gi%')#**400F2JJ//335G5G5GHHHHHr7   c                    | j         j        }|j        j        |j        j        z                       d          }t          j        |j        j                  |j        j	        z                       d          }| 
                    t          ||                              ||                                          g d           d S )Nrs   ly))r   q1p3)r}   q2p2)r   q3p1)r?   r+   rU   rd   re   rx   r   lowerrf   rh   rN   r   rT   desc)rK   r   rs   r   s       r5   test_composed_multiplez'OrderByLabelTest.test_composed_multiple   s    &gi%')#**400j##egi/66t<<2rNN##B		22333	
 	
 	
 	
 	
r7   c                     | j         j        }|j        j                            d          }|                     t          |                              |                                          g d           d S )Nrs   )rw   rv   ru   )	r?   r+   rU   rd   rx   rN   r   rT   r   ry   s      r5   test_plain_descz OrderByLabelTest.test_plain_desc   s`    &WY__T""F2JJ//		::<N<N<NOOOOOr7   c                 
   | j         j        }|j        j        |j        j        z                       d          }|                     t          |                              |	                                          g d           d S )Nrs   )r~   r|   rw   )
r?   r+   rU   rd   re   rx   rN   r   rT   r   ry   s      r5   test_composed_int_descz'OrderByLabelTest.test_composed_int_desc   sk    &gi%')#**400F2JJ//		::<N<N<NOOOOOr7   c                 J   | j         j        }|j        j        |j        j        z                       d          }t          t          j        |j        j	                  |          
                    |                              |          }|                     |g d           d S )Nrs   ))r9   r   )r9   r}   )r9   r   )r?   r+   rU   rd   re   rx   r   r   countr,   group_byrT   rN   )rK   r   exprstmts       r5   test_group_by_composedz'OrderByLabelTest.test_group_by_composed   s    &	EGI%,,T224:egj))40099$??HHNN 	 	D":":":;;;;;r7   N)rZ   r[   r\   __doc__r]   r^   r6   rC   rN   rz   r   r   r   r   r   rR   group_by_complex_expressionr   r`   r7   r5   rb   rb   W   s          K	
 	
 [	
 
 
 [
9 9 9I I I
I I I

 
 
P P P
P P P
 1< < 21< < <r7   rb   c                       e Zd ZdZdZd ZdS )ValuesExpressionTest)table_value_constructorTc                 (   t          t          dt                    t          dt                    d                              g d          }t          |                    t          |                                                    g d           d S )Nr,   name	my_values)r   ))r9   name1)r   name2)r   name3)	r%   r   r   r   r/   r	   r>   r   all)rK   rB   
value_exprs      r5   test_tuplesz ValuesExpressionTest.test_tuples   s    4!!6&&#9#9
 
 

$999
:
: 	 	vj11226688666	
 	
 	
 	
 	
r7   N)rZ   r[   r\   __requires__r]   r   r`   r7   r5   r   r      s-        /LK
 
 
 
 
r7   r   c                      e Zd ZdZed             Zed             Z	 d)dZd*dZd Z	d	 Z
ej        j        d
             Zej        j        d             Z ej        g dg dg dd          ej        j        d                         Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Z ej        j        d             Z!ej        j        ej        j"        d                         Z#ej        j        d             Z$ej        j        d              Z%ej        j&        d!             Z'ej        j&        ej        j(        d"                         Z)ej        j&        ej        j(        d#                         Z*ej        j+        d$             Z,ej        j+        ej        j(        d%                         Z-ej        j&        ej        j+        d&                         Z.ej        j&        ej        j+        ej        j(        d'                                     Z/d(S )+FetchLimitOffsetTestTc           
          t          d|t          dt          d          t          dt                    t          dt                               d S Nr+   r,   Tr-   rd   re   r   r   r   r2   s     r5   r6   z"FetchLimitOffsetTest.define_tables   P    4d3333  3  	
 	
 	
 	
 	
r7   c                     |                     | j        j                                        ddddddddddddddddddddg           d S )Nr9   r   r,   rd   re   r   rn   r}      r=   rA   s     r5   rC   z FetchLimitOffsetTest.insert_data   s~    J!((**qq))qq))qq))qq))qq))		
 		
 		
 		
 		
r7   r`   Fc                 r   |r~|                     ||                                          }t          t          |          t          |                     t          t	          |          t	          |                     d S t          |                     ||                                          |           d S rE   )r>   rI   r	   lenset)rK   rB   r   rL   paramsset_	query_ress          r5   rN   z#FetchLimitOffsetTest._assert_result   s      	G"**66::CCEEIIF,,,IF,,,,, 
""6622;;==vFFFFFr7   c                     t           j                                        5 }t          |                    ||                                          |           d d d            d S # 1 swxY w Y   d S rE   )r   rG   rH   r	   exec_driver_sqlrI   rK   r   rL   r   rM   s        r5   _assert_result_strz'FetchLimitOffsetTest._assert_result_str   s    Y   	ID$$VV44==??HHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I   7A##A'*A'c                 &   | j         j        }t          |                              |j        j                  }|                     ||                    d          ddg           |                     ||                    d          g d           d S Nr   r9   r9   r   r   r   r   r   r   r   r   r   rn   )r?   r+   r   rT   rU   r,   rN   limit)rK   rB   r   r   s       r5   test_simple_limitz&FetchLimitOffsetTest.test_simple_limit   s    &e}}%%egj11JJqMM	"	
 	
 	

 	JJqMM---	
 	
 	
 	
 	
r7   c                 f   | j         j        }t          |j        j                                      d                                          }t          t          |          t          |                                                                                    }| 	                    ||dg           d S )Nr9   ru   )
r?   r+   r   rU   r,   r   scalar_subqueryr$   subqueryrN   )rK   rB   r   r   us        r5    test_limit_render_multiple_timesz5FetchLimitOffsetTest.test_limit_render_multiple_times   s    &egj!!''**::<<&,,t--6688??AA	
 	
 	
 	
 	
r7   c                 v   | j         j        }|                     |t          |                              |j        j                                      d          ddg           |                     |t          |                              |j        j                                      d          g d           d S r   r?   r+   rN   r   rT   rU   r,   fetchrK   rB   r   s      r5   test_simple_fetchz&FetchLimitOffsetTest.test_simple_fetch   s    &5MM""57:..44Q77	"	
 	
 	

 	5MM""57:..44Q77---	
 	
 	
 	
 	
r7   c                 v   | j         j        }|                     |t          |                              |j        j                                      d          g d           |                     |t          |                              |j        j                                      d          ddg           d S )Nr   r   rn   rn   r}   r}   rn   r   r   r   r   r?   r+   rN   r   rT   rU   r,   offsetr   s      r5   test_simple_offsetz'FetchLimitOffsetTest.test_simple_offset  s    &5MM""57:..55a88---	
 	
 	

 	5MM""57:..55a88	"	
 	
 	
 	
 	
r7   )r   r   r   r9   r   r   )r   r   r   )r   r9   r   r   casesargnamesc                 J   | j         j        }|                    i           }g d}|D ]y\  }}||||z            }|                     |t	          |                              |j        j                                      |          	                    |          |           zd S )N)compiled_cacher   r   r   r   r   )
r?   r+   execution_optionsrN   r   rT   rU   r,   r   r   )rK   rB   r   r   assert_datar   r   expecteds           r5   test_simple_limit_offsetz-FetchLimitOffsetTest.test_simple_limit_offset  s     &111DD
MMM" 	 	ME6"6FUN#:;Hu&&uwz2288??FFvNN   	 	r7   c                    | j         j        }|                     |t          |                              |j        j                                      d                              d          ddg           |                     |t          |                              |j        j                                      d                              d          g d           d S )Nr   r9   r   r   r   r   	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_simple_fetch_offsetz-FetchLimitOffsetTest.test_simple_fetch_offset*  s    &5MM""57:..44Q77>>qAA	"	
 	
 	
 	5MM""57:..44Q77>>qAA---	
 	
 	
 	
 	
r7   c                     | j         j        }|                     |t          |                              d          g dd           d S )N
   r   Tr   )r?   r+   rN   r   r   r   s      r5   test_fetch_offset_no_orderz/FetchLimitOffsetTest.test_fetch_offset_no_order9  sY    &5MM##CCC	 	 	
 	
 	
 	
 	
r7   c                 v   | j         j        }|                     |t          |                              |j        j                                      d          g d           |                     |t          |                              |j        j                                      d          g d           d S )Nr   r   r9   r   r   r   r   r   r   s      r5   test_simple_offset_zeroz,FetchLimitOffsetTest.test_simple_offset_zeroC  s    &5MM""57:..55a88CCC	
 	
 	
 	5MM""57:..55a88888	
 	
 	
 	
 	
r7   c                 `   | j         j        }t          |                              |j        j                                      d                              d          }|                    t          j
        j        ddi          }t          |          }|                     |ddg           dS 	z7test that 'literal binds' mode works - no bound params.r   r9   literal_bindsT)dialectcompile_kwargsr   r   N)r?   r+   r   rT   rU   r,   r   r   compiler   rG   r   strr   rK   r   r   sqls       r5   test_limit_offset_nobindsz.FetchLimitOffsetTest.test_limit_offset_nobindsR       &e}}%%egj1177::AA!DDllI%6M  
 
 #hhi%;<<<<<r7   c                 `   | j         j        }t          |                              |j        j                                      d                              d          }|                    t          j
        j        ddi          }t          |          }|                     |ddg           dS r   )r?   r+   r   rT   rU   r,   r   r   r   r   rG   r   r   r   r   s       r5   test_fetch_offset_nobindsz.FetchLimitOffsetTest.test_fetch_offset_nobinds_  r   r7   c                    | j         j        }|                     |t          |                              |j        j                                      t          d                    ddgddi           |                     |t          |                              |j        j                                      t          d                    g dddi           d S )Nlr   r   r   r   r   r   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_bound_limitz%FetchLimitOffsetTest.test_bound_limitl  s    &5MM""57:..44Ys^^DD	"8	 	 	
 	
 	
 	5MM""57:..44Ys^^DD---8	 	 	
 	
 	
 	
 	
r7   c                    | j         j        }|                     |t          |                              |j        j                                      t          d                    g dddi           |                     |t          |                              |j        j                                      t          d                    g dddi           d S )Nor   r   r   r   r9   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_bound_offsetz&FetchLimitOffsetTest.test_bound_offset}  s    &5MM""57:..55innEE---8	 	 	
 	
 	
 	5MM""57:..55innEE8888	 	 	
 	
 	
 	
 	
r7   c                 >   | j         j        }|                     |t          |                              |j        j                                      t          d                    	                    t          d                    ddgddd           |                     |t          |                              |j        j                                      t          d                    	                    t          d                    g d	d
dd           d S )Nr   r   r   r   r   r9   )r   r   r   r   r   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_bound_limit_offsetz,FetchLimitOffsetTest.test_bound_limit_offset      &5MMXegj!!U9S>>""VIcNN##	"## 	 	
 	
 	
 	5MMXegj!!U9S>>""VIcNN##---## 	 	
 	
 	
 	
 	
r7   c                 >   | j         j        }|                     |t          |                              |j        j                                      t          d                    	                    t          d                    ddgddd           |                     |t          |                              |j        j                                      t          d                    	                    t          d                    g d	d
dd           d S )Nfr   r   r   r   r9   )r   r   r   r   r   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_bound_fetch_offsetz,FetchLimitOffsetTest.test_bound_fetch_offset  r   r7   c           	         | j         j        }|                     |t          |                              |j        j                                      t          d          t          d          z             ddg           d S )N12r   r   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_expr_offsetz%FetchLimitOffsetTest.test_expr_offset  su    &5MMXegj!!VN3''.*=*==>>	"	
 	
 	
 	
 	
r7   c           	         | j         j        }|                     |t          |                              |j        j                                      t          d          t          d          z             g d           d S )Nr  r  r   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_expr_limitz$FetchLimitOffsetTest.test_expr_limit  sv    &5MMXegj!!U>#&&)<)<<==---	
 	
 	
 	
 	
r7   c           	      d   | j         j        }|                     |t          |                              |j        j                                      t          d          t          d          z             	                    t          d          t          d          z             ddg           d S Nr  r   r   
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_expr_limit_offsetz+FetchLimitOffsetTest.test_expr_limit_offset  s    &5MMXegj!!U>#&&)<)<<==VN3''.*=*==>>	"	
 	
 	
 	
 	
r7   c           	      d   | j         j        }|                     |t          |                              |j        j                                      t          d          t          d          z             	                    t          d          t          d          z             ddg           d S r  )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_expr_fetch_offsetz+FetchLimitOffsetTest.test_expr_fetch_offset  s     &5MMXegj!!U>#&&)<)<<==VN3''.*=*==>>	"	
 	
 	
 	
 	
r7   c           	      6   | j         j        }|                     |t          |                              |j        j                                      d                              t          d          t          d          z             ddg           |                     |t          |                              |j        j                                      d                              t          d          t          d          z             g d           d S )Nr   r  r   r   r   r   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_simple_limit_expr_offsetz2FetchLimitOffsetTest.test_simple_limit_expr_offset  s    &5MMXegj!!U1XXVN3''.*=*==>>	"	
 	
 	
 	5MMXegj!!U1XXVN3''.*=*==>>---	
 	
 	
 	
 	
r7   c           	      6   | j         j        }|                     |t          |                              |j        j                                      t          d          t          d          z             	                    d          ddg           |                     |t          |                              |j        j                                      t          d          t          d          z             	                    d          ddg           d S )Nr  r   r   r   r9   r   r	  r   s      r5   test_expr_limit_simple_offsetz2FetchLimitOffsetTest.test_expr_limit_simple_offset   s    &5MMXegj!!U>#&&)<)<<==VAYY	"	
 	
 	
 	5MMXegj!!U>#&&)<)<<==VAYY	"	
 	
 	
 	
 	
r7   c                    | j         j        }|                     |t          |                              |j        j                                                                      dd          ddgd           |                     |t          |                              |j        j                                                                      dd          g dd           d S )	Nr9   T	with_tiesr   r   r   r   r   	r?   r+   rN   r   rT   rU   rd   r   r   r   s      r5   test_simple_fetch_tiesz+FetchLimitOffsetTest.test_simple_fetch_ties  s    &5MM""579>>#3#344::1:MM	"	 	 	
 	
 	
 	5MM""579>>#3#344::1:MM---	 	 	
 	
 	
 	
 	
r7   c                 z   | j         j        }|                    t          |                              |j        j                                      dd                              d                    	                                }t          |d         d           t          t          |          h d           d S )Nr   Tr  r   r      r   r   r   r?   r+   r>   r   rT   rU   rd   r   r   rI   r	   r   rK   rB   r   fas       r5   test_fetch_offset_tiesz+FetchLimitOffsetTest.test_fetch_offset_ties&  s     &5MMXegi  U1U%%VAYY	
 

 (** 	 	BqE9CGG66677777r7   c                    | j         j        }|                     |t          |                              |j        j                                      dd                              d          ddg           |                     |t          |                              |j        j                                      dd                              d          dd	g           d S )
Nr   Tr  r9   r   r   r   r   r   )	r?   r+   rN   r   rT   rU   rd   r   r   r   s      r5   #test_fetch_offset_ties_exact_numberz8FetchLimitOffsetTest.test_fetch_offset_ties_exact_number3  s     &5MMXegi  U1U%%VAYY	"	
 	
 	
 	5MMXegi  U1U%%VAYY	"	
 	
 	
 	
 	
r7   c                     | j         j        }|                     |t          |                              |j        j                                      dd          dg           d S )N   Tpercentr   r   r   s      r5   test_simple_fetch_percentz.FetchLimitOffsetTest.test_simple_fetch_percentI  sd    &5MM""57:..44R4FFK	
 	
 	
 	
 	
r7   c                     | j         j        }|                     |t          |                              |j        j                                      dd                              d          ddg           d S )N(   Tr   r9   r   r   r   r   s      r5   test_fetch_offset_percentz.FetchLimitOffsetTest.test_fetch_offset_percentR  sq     &5MMXegj!!U2tU$$VAYY	"	
 	
 	
 	
 	
r7   c                     | j         j        }|                     |t          |                              |j        j                                                                      ddd          ddgd           d S )Nr  Tr!  r  r   r   r   r  r   s      r5   test_simple_fetch_percent_tiesz3FetchLimitOffsetTest.test_simple_fetch_percent_ties_  sz     &5MMXeginn&&''U2ttU44	" 	 	
 	
 	
 	
 	
r7   c                 |   | j         j        }|                    t          |                              |j        j                                      ddd                              d                    	                                }t          |d         d           t          t          |          h d           d S )Nr$  Tr'  r   r   r   r  r  r  s       r5   test_fetch_offset_percent_tiesz3FetchLimitOffsetTest.test_fetch_offset_percent_tiesl  s     &5MMXegi  U2ttU44VAYY	
 

 (** 	 	BqE9CGG66677777r7   N)r`   Fr`   )0rZ   r[   r\   r]   r^   r6   rC   rN   r   r   r   r   rR   fetch_firstr   r   r   combinationsr   r   fetch_no_order_byr   r   r   r   bound_limit_offsetr   r   r   r   sql_expression_limit_offsetr  r  r
  fetch_expressionr  r  r  
fetch_tiesr  fetch_offset_with_optionsr  r  fetch_percentr"  r%  r(  r*  r`   r7   r5   r   r      s       K
 
 [
 

 

 [

 ;@	G 	G 	G 	GI I I I
 
 

 
 
 !
 
 "!
 
 
 
 W	!	!	!	!	!	!	!	!	!	       !
 
 "!
 '
 
 ('
 
 
 
 
= 
= 
= !
= 
= "!
= (
 
 )(
  (
 
 )(
  (
 
 )(
, !
 
 "!
, 1
 
 21
 1
 
 21
 1	
 	
 21	
 !&	
 	
 '& "!	
 1
 
 21
( 1
 
 21
(  
 
 ! 
   /	8 	8 0/ ! 	8  /
 
 0/ ! 
( #
 
 $#
 #/	
 	
 0/ $#	
  #	
 	
 $# ! 	
  #/	8 	8 0/ $# ! 	8 	8 	8r7   r   c                   X    e Zd ZdZdZdZed             Zed             Zd Z	d Z
d Zd	S )
SameNamedSchemaTableTestztests for #7471T)schemasc           
          t          d|t          dt          d          t          j                   t          d|t          dt          d          t          dt          d                     d S )	Nr+   r,   Tr-   )schemasome_table_idFnullable)r   r   r   r   test_schemar2   s     r5   r6   z&SameNamedSchemaTableTest.define_tables  s    4d333%		
 	
 	
 	
 	4d333	  	
	
 
	
 
	
 
	
 
	
r7   c                     |                      ddt          j        z            \  }}|                    |                                ddi           |                    |                                ddd           d S )Nr+   %s.some_tabler,   r9   )r,   r:  )r?   r   r=  r>   r@   )r3   rB   r+   some_table_schemas       r5   rC   z$SameNamedSchemaTableTest.insert_data  s    (+

/F,>>)
 )
%
% 	,3355ayAAA:,,..q10M0MNNNNNr7   c           
      2   |                      ddt          j        z            \  }}t          |                    t          ||                              |||j        j        |j        j	        k                        
                                d           d S )Nr+   r?  r9   r9   r9   )r?   r   r=  r	   r>   r   	join_fromrU   r:  r,   firstrK   rB   r+   r@  s       r5   test_simple_join_both_tablesz5SameNamedSchemaTableTest.test_simple_join_both_tables  s    (,/F,>>)
 )
%
% 	z#455??%L.2C2E2HH   egg		
 		
 		
 		
 		
r7   c           
      r   |                      ddt          j        z            \  }}t          |                    t          |                              |||j        j        |j        j	        k              
                    |j        j	        dk                                                        d           d S )Nr+   r?  r9   r9   r9   )r?   r   r=  r	   r>   r   rC  rU   r:  r,   whererD  rE  s       r5   !test_simple_join_whereclause_onlyz:SameNamedSchemaTableTest.test_simple_join_whereclause_only  s    (,/F,>>)
 )
%
% 	z""%L.2C2E2HH 
 z|!+,,  egg	
 	
 	
 	
 	
r7   c           
      f   |                      ddt          j        z            \  }}t          |                              |||j        j        |j        j        k                                  |j        j        dk              	                                }t          |                    t          ||j        j                                      |||j        j        |j        j        k                                  |j        j        dk                                                        d           d S )Nr+   r?  r9   rB  )r?   r   r=  r   rC  rU   r:  r,   rI  r   r	   r>   rD  )rK   rB   r+   r@  subqs        r5   test_subqueryz&SameNamedSchemaTableTest.test_subquery  s   (,/F,>>)
 )
%
%
 :Y!*.?.A.DD 
 U:<?a'((XZZ 	 	z469--L.$&); 
 z|!+,,  egg	
 	
 	
 	
 	
r7   N)rZ   r[   r\   r   r]   r   r^   r6   rC   rF  rJ  rM  r`   r7   r5   r6  r6  {  s        KL
 
 [
& O O [O
 
 
 
 
 
$
 
 
 
 
r7   r6  c                   d    e Zd ZdZddZed             Zed             Zd Zd Z	d Z
d	 Zd
 ZdS )JoinTestTr`   c                     t           j                                        5 }t          |                    ||                                          |           d d d            d S # 1 swxY w Y   d S rE   rF   r   s        r5   rN   zJoinTest._assert_result      Y   	ADVV,,5577@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	Ar   c                     t          d|t          dt          d                     t          d|t          dt          d          t          dt          d          d	                     d S )
Nar,   Tr-   ba_idza.idFr;  )r   r   r   r   r2   s     r5   r6   zJoinTest.define_tables  sq    c8VD'tDDDEEE4d3336:f-->>>		
 	
 	
 	
 	
r7   c           	         |                     | j        j                                        ddiddiddiddiddig           |                     | j        j                                        ddddddddddddg           d S )Nr,   r9   r   r   rn   r}   )r,   rU  )r>   r?   rS  r@   rT  rA   s     r5   rC   zJoinTest.insert_data  s    JL!!AYq	D!9tQi$C	
 	
 	

 	JL!!!$$!$$!$$!$$		
 	
 	
 	
 	
r7   c                 $   |                      dd          \  }}t          ||                              |                    |                                        |j        j        |j        j                  }|                     |g d           d S NrS  rT  )rB  )r9   r   r9   )r   rn   r   )r   r}   r   r?   r   select_fromjoinrT   rU   r,   rN   rK   rS  rT  r   s       r5   test_inner_join_fkzJoinTest.test_inner_join_fk   y    {{3$$1a||''q		22;;ACFACFKKD"N"N"NOOOOOr7   c           	      |   |                      dd          \  }}t          ||                              |                    |t	                                                              |j        j        |j        j                  }|                     |d t          j
        g dg d          D                        d S )NrS  rT  c                 (    g | ]\  \  }\  }}|||fS r`   r`   ).0rS  rT  rU   s       r5   
<listcomp>z1JoinTest.test_inner_join_true.<locals>.<listcomp>  s8        DQ&1a Aq	  r7   )ru   rv   rw   rn   r|   )rH  r   )rn   r   )r}   r   )r?   r   rZ  r[  r!   rT   rU   r,   rN   	itertoolsproductr\  s       r5   test_inner_join_truezJoinTest.test_inner_join_true  s    {{3$$1 1aLL[466**++Xacfacf%% 	 	 $-$5222444% %  		
 		
 		
 		
 		
r7   c                 :   |                      dd          \  }}t          ||                              |                    |t	                                                              |j        j        |j        j                  }|                     |g            d S )NrS  rT  )	r?   r   rZ  r[  r   rT   rU   r,   rN   r\  s       r5   test_inner_join_falsezJoinTest.test_inner_join_false  s    {{3$$1 1aLL[577++,,Xacfacf%% 	 	D"%%%%%r7   c                 >   |                      dd          \  }}t          ||                              |                    |t	                                                              |j        j        |j        j                  }|                     |g d           d S )NrS  rT  ))r9   NN)r   NN)r   NN)rn   NN)r}   NN)	r?   r   rZ  	outerjoinr   rT   rU   r,   rN   r\  s       r5   test_outer_join_falsezJoinTest.test_outer_join_false&  s    {{3$$1 1aLL[Q0011Xacfacf%% 	 	  		
 		
 		
 		
 		
r7   c                 $   |                      dd          \  }}t          ||                              |                    |                                        |j        j        |j        j                  }|                     |g d           d S rX  rY  r\  s       r5   test_outer_join_fkzJoinTest.test_outer_join_fk:  r^  r7   Nr+  )rZ   r[   r\   r]   rN   r^   r6   rC   r]  rf  rh  rk  rm  r`   r7   r5   rO  rO    s        KA A A A 
 
 [
 
 
 [
 P P P
 
 
(	& 	& 	&
 
 
(P P P P Pr7   rO  c                       e Zd ZdZed             Zed             ZddZd Zd Z	e
j        j        e
j        j        d                         Ze
j        j        d	             Zd
 Ze
j        j        d             Zd ZdS )CompoundSelectTestTc           
          t          d|t          dt          d          t          dt                    t          dt                               d S r   r   r2   s     r5   r6   z CompoundSelectTest.define_tablesE  r   r7   c           
          |                     | j        j                                        ddddddddddddddddg           d S )Nr9   r   r   r   rn   r}   r=   rA   s     r5   rC   zCompoundSelectTest.insert_dataO  sq    J!((**qq))qq))qq))qq))		
 	
 	
 	
 	
r7   r`   c                     t           j                                        5 }t          |                    ||                                          |           d d d            d S # 1 swxY w Y   d S rE   rF   r   s        r5   rN   z!CompoundSelectTest._assert_result[  rQ  r   c                 h   | j         j        }t          |                              |j        j        dk              }t          |                              |j        j        dk              }t          ||          }|                     |                    |j	        j                  ddg           d S Nr   r   r   r   )
r?   r+   r   rI  rU   r,   r$   rN   rT   selected_columnsrK   r   s1s2u1s        r5   test_plain_unionz#CompoundSelectTest.test_plain_union_  s    &E]]  q11E]]  q112r]]KK+.//)Y1G	
 	
 	
 	
 	
r7   c                    | j         j        }t          |                              |j        j        dk              }t          |                              |j        j        dk              }t          ||                                                                          }|                     |	                    |j
        j                  ddg           d S rt  )r?   r+   r   rI  rU   r,   r$   aliasrN   rT   ru  rv  s        r5   test_select_from_plain_unionz/CompoundSelectTest.test_select_from_plain_unioni  s    &E]]  q11E]]  q112r]]  ""))++KK+.//)Y1G	
 	
 	
 	
 	
r7   c                 N   | j         j        }t          |                              |j        j        dk                                  d                              |j        j                  }t          |                              |j        j        dk                                  d                              |j        j                  }t          ||                              d          }| 	                    |                    |j
        j                  ddg           d S Nr   r9   r   r   r   )r?   r+   r   rI  rU   r,   r   rT   r$   rN   ru  rv  s        r5   &test_limit_offset_selectable_in_unionsz9CompoundSelectTest.test_limit_offset_selectable_in_unionss  s     &E]]  q1177::CCEGJOOE]]  q1177::CCEGJOO2r]]  ##KK+.//)Y1G	
 	
 	
 	
 	
r7   c                    | j         j        }t          |                              |j        j        dk                                  |j        j                  }t          |                              |j        j        dk                                  |j        j                  }t          ||                              d          }| 	                    |                    |j
        j                  ddg           d S rt  )r?   r+   r   rI  rU   r,   rT   r$   r   rN   ru  rv  s        r5   "test_order_by_selectable_in_unionsz5CompoundSelectTest.test_order_by_selectable_in_unions  s    &E]]  q11::57:FFE]]  q11::57:FF2r]]  ##KK+.//)Y1G	
 	
 	
 	
 	
r7   c                    | j         j        }t          |                              |j        j        dk                                              }t          |                              |j        j        dk                                              }t          ||                              d          }| 	                    |
                    |j        j                  ddg           d S rt  )r?   r+   r   rI  rU   r,   distinctr$   r   rN   rT   ru  rv  s        r5   "test_distinct_selectable_in_unionsz5CompoundSelectTest.test_distinct_selectable_in_unions  s    &E]]  q11::<<E]]  q11::<<2r]]  ##KK+.//)Y1G	
 	
 	
 	
 	
r7   c                    | j         j        }t          |                              |j        j        dk                                  d                              |j        j                  }t          |                              |j        j        dk                                  d                              |j        j                  }t          ||          	                                }| 
                    |                                                    d                              |j        j                  ddg           d S r  )r?   r+   r   rI  rU   r,   r   rT   r$   r|  rN   rv  s        r5   &test_limit_offset_in_unions_from_aliasz9CompoundSelectTest.test_limit_offset_in_unions_from_alias  s    &E]]  q1177::CCEGJOOE]]  q1177::CCEGJOO 2r]]  ""IIKKa  ))"$'22Y	4J	
 	
 	
 	
 	
r7   c                    | j         j        }t          |                              |j        j        dk                                  d                              |j        j                                                                                  }t          |                              |j        j        dk                                  d                              |j        j                                                                                  }t          ||                              d          }| 
                    |                    |j        j                  ddg           d S r  )r?   r+   r   rI  rU   r,   r   rT   r|  r$   rN   ru  rv  s        r5   .test_limit_offset_aliased_selectable_in_unionszACompoundSelectTest.test_limit_offset_aliased_selectable_in_unions  s   &5MMU57:?##U1XXXegj!!UWWVXX 	 5MMU57:?##U1XXXegj!!UWWVXX 	 2r]]  ##KK+.//)Y1G	
 	
 	
 	
 	
r7   Nr+  )rZ   r[   r\   r]   r^   r6   rC   rN   rz  r}  r   rR   order_by_col_from_union/parens_in_union_contained_select_w_limit_offsetr  0parens_in_union_contained_select_wo_limit_offsetr  r  r  r  r`   r7   r5   ro  ro  B  s       K
 
 [
 	
 	
 [	
A A A A
 
 

 
 
 -E
 
 FE .-
 F
 
 GF

 
 
 E	
 	
 FE	

 
 
 
 
r7   ro  c                       e Zd ZdZdZed             Zed             Zd Zd Z	d Z
d Zej        j        d	             Zej        j        d
             ZdS )PostCompileParamsTestT)standard_cursor_sqlc                     t          d|t          dt          d          t          dt                    t          dt                    t          dt          d                               d S 	Nr+   r,   Tr-   rd   re   zrg   r1   r2   s     r5   r6   z#PostCompileParamsTest.define_tables  c    4d3333  3  3r

##	
 	
 	
 	
 	
r7   c                     |                     | j        j                                        dddddddddddddddddd	d
dg           d S Nr9   r   z1)r,   rd   re   r  r   z2rn   z3r}   z4r=   rA   s     r5   rC   z!PostCompileParamsTest.insert_data  y    J!((**qqt44qqt44qqt44qqt44		
 	
 	
 	
 	
r7   c                     | j         j        }t          |j        j                                      |j        j        t          dd          k              }|                     |di            d S )Nrf   Tliteral_executezKSELECT some_table.id FROM some_table WHERE some_table.x = __[POSTCOMPILE_q]	r?   r+   r   rU   r,   rI  rd   r   assert_compilerK   r   r   s      r5   test_compilez"PostCompileParamsTest.test_compile  su    &egj!!''GI3====
 
 	5		
 	
 	
 	
 	
r7   c                     | j         j        }t          |j        j                                      |j        j        t          ddd          k              }|                     |di d           d S )Nrf   r   Tr  z<SELECT some_table.id FROM some_table WHERE some_table.x = 10)r   r  r  s      r5   test_compile_literal_bindsz0PostCompileParamsTest.test_compile_literal_binds  s}    &egj!!''GI3DAAAA
 
 	J	 	 	
 	
 	
 	
 	
r7   c                 2   | j         j        }t          |j        j                                      |j        j        t          dd          k              }|                                 5 }t          j
                                        5 }|                    |t          d                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    t          dt          j
        j        j        rdni                      d S )Nrf   Tr  r   rf   z>SELECT some_table.id 
FROM some_table 
WHERE some_table.x = 10r`   )r?   r+   r   rU   r,   rI  rd   r   sql_execution_asserterr   rG   rH   r>   dictassert_r   r   
positionalrK   r   r   asserterrM   s        r5   test_executez"PostCompileParamsTest.test_execute  sx   &egj!!''GI3====
 
 ((** 	/h""$$ /T4":::.../ / / / / / / / / / / / / / /	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	,i'2: 	
 	
 	
 	
 	
s6   *C	%B:.C:B>	>CB>	CCCc           	      V   | j         j        }t          |j        j                                      |j        j                            t          ddd                              }| 	                                5 }t          j                                        5 }|                    |t          g d                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    t!          dt          j        j        j        rdni                      d S )Nrf   T	expandingr  )r}   r   r   r  zFSELECT some_table.id 
FROM some_table 
WHERE some_table.x IN (5, 6, 7)r`   )r?   r+   r   rU   r,   rI  rd   r
   r   r  r   rG   rH   r>   r  r  r   r   r  r  s        r5   +test_execute_expanding_plus_literal_executezAPostCompileParamsTest.test_execute_expanding_plus_literal_execute  s   &egj!!''GIMM)C4NNNOO
 
 ((** 	6h""$$ 6T4)))#4#4#45556 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	4i'2: 	
 	
 	
 	
 	
s6   :C#'C C#C	C#C	C##C'*C'c           	         | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          ddd                              }|                                 5 }t          j                                        5 }|                    |t!          ddg                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    t%          dt          j        j        j        rdnd	z  t          j        j        j        rd
ni                      d S )Nrf   Tr  )r}   r   )      r  zbSELECT some_table.id 
FROM some_table 
WHERE (some_table.x, some_table.y) IN (%s(5, 10), (12, 18))VALUES  r`   )r?   r+   r   rU   r,   rI  r"   rd   re   r
   r   r  r   rG   rH   r>   r  r  r   r   tuple_in_valuesr  r  s        r5   1test_execute_tuple_expanding_plus_literal_executezGPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_execute  s   &egj!!''579egi((,,#tDDD 
 
 ((** 	@h""$$ @T47H*=#>#>#>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	+ !'	 1 AI99rK i'2: 	
 	
 	
 	
 	
6   C;1'C$C;$C(	(C;+C(	,C;;C?C?c           	         | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          ddd                              }|                                 5 }t          j                                        5 }|                    |t!          ddg                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    t%          dt          j        j        j        rdnd	z  t          j        j        j        rd
ni                      d S )Nrf   Tr  )r}   r  )r  r  r  zfSELECT some_table.id 
FROM some_table 
WHERE (some_table.x, some_table.z) IN (%s(5, 'z1'), (12, 'z3'))r  r  r`   )r?   r+   r   rU   r,   rI  r"   rd   r  r
   r   r  r   rG   rH   r>   r  r  r   r   r  r  r  s        r5   ?test_execute_tuple_expanding_plus_literal_heterogeneous_executezUPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_heterogeneous_execute1  s   &egj!!''579egi((,,#tDDD 
 
 ((** 	Dh""$$ DT49j*A#B#B#BCCCD D D D D D D D D D D D D D D	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	/ !'	 1 AI99rK i'2: 	
 	
 	
 	
 	
r  N)rZ   r[   r\   r]   r   r^   r6   rC   r  r  r  r  r   rR   tuple_inr  r  r`   r7   r5   r  r    s         K+L
 
 [
 	
 	
 [	

 
 

 
 

 
 
&
 
 
& 
 
 
. 
 
 
 
 
r7   r  c                      e Zd ZdZed             Zed             Zd$dZd Zd Z	e
j        j        d             Ze
j        j        d	             Ze
j        j        d
             Ze
j        j        d             Zd Zd Zd Zd Zd Zd Ze
j        j        d             Ze
j        j        d             Ze
j        j        d             Ze
j        j        d             Ze
j        j        d             Ze
j        j        d             Ze
j        j        d             Zd Zd Z d Z!d Z"d Z#d Z$d Z%d  Z&d! Z'd" Z(d#S )%ExpandingBoundInTestTc                     t          d|t          dt          d          t          dt                    t          dt                    t          dt          d                               d S r  r1   r2   s     r5   r6   z"ExpandingBoundInTest.define_tablesM  r  r7   c                     |                     | j        j                                        dddddddddddddddddd	d
dg           d S r  r=   rA   s     r5   rC   z ExpandingBoundInTest.insert_dataX  r  r7   r`   c                     t           j                                        5 }t          |                    ||                                          |           d d d            d S # 1 swxY w Y   d S rE   rF   r   s        r5   rN   z#ExpandingBoundInTest._assert_resultd  rQ  r   c                    | j         j        }t          |j        j                                      |j        j                            t          d                                                  |j        j	                            t          d                              
                    |j        j                  }|                     |g g g d           d S )Nrf   rh   )rf   rh   r   )r?   r+   r   rU   r,   rI  rd   r
   r   re   rT   rN   r  s      r5   "test_multiple_empty_sets_bindparamz7ExpandingBoundInTest.test_multiple_empty_sets_bindparamh  s     &57:U579==30011U579==30011Xegj!!	 	 	D"2B-?-?@@@@@r7   c                 v   | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                            g                     	                    |j        j                  }| 
                    |g            d S rE   )r?   r+   r   rU   r,   rI  rd   r
   re   rT   rN   r  s      r5   test_multiple_empty_sets_directz4ExpandingBoundInTest.test_multiple_empty_sets_directt  s     &57:U579==$$%%U579==$$%%Xegj!!	 	 	D"%%%%%r7   c                 h   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          d                                                  |j        j                  }|                     |g dg i           d S Nrf   r   r?   r+   r   rU   r,   rI  r"   rd   r  r
   r   rT   rN   r  s      r5   )test_empty_heterogeneous_tuples_bindparamz>ExpandingBoundInTest.test_empty_heterogeneous_tuples_bindparam      &57:U6%')UWY//33IcNNCCDDXegj!! 	
 	D"c2Y77777r7   c                 ~      j         j         fd} |g g             |g dg d            |g g            d S )Nc                 0   t          j        j                                      t	          j        j        j        j                                      |                                         j        j                  }	                    ||           d S rE   )
r   rU   r,   rI  r"   rd   r  r
   rT   rN   valr   r   rK   r   s      r5   gozGExpandingBoundInTest.test_empty_heterogeneous_tuples_direct.<locals>.go  s    uwz""vegi3377<<==%'*%% 
 h/////r7   )r   r  )r   r  )rn   r  rv   rw   rc  r?   r+   rK   r  r   s   ` @r5   &test_empty_heterogeneous_tuples_directz;ExpandingBoundInTest.test_empty_heterogeneous_tuples_direct  sp    &	0 	0 	0 	0 	0 	0 	2r



,,,.@.@.@AAA
2r




r7   c                 h   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          d                                                  |j        j                  }|                     |g dg i           d S r  r?   r+   r   rU   r,   rI  r"   rd   re   r
   r   rT   rN   r  s      r5   'test_empty_homogeneous_tuples_bindparamz<ExpandingBoundInTest.test_empty_homogeneous_tuples_bindparam  r  r7   c                 ~      j         j         fd} |g g             |g dg d            |g g            d S )Nc                 0   t          j        j                                      t	          j        j        j        j                                      |                                         j        j                  }	                    ||           d S rE   )
r   rU   r,   rI  r"   rd   re   r
   rT   rN   r  s      r5   r  zEExpandingBoundInTest.test_empty_homogeneous_tuples_direct.<locals>.go  r  r7   ))r9   r   r   r   r   rn   rt   r  r  s   ` @r5   $test_empty_homogeneous_tuples_directz9ExpandingBoundInTest.test_empty_homogeneous_tuples_direct  sp    &	0 	0 	0 	0 	0 	0 	2r



###%7%7%7888
2r




r7   c                 @   | j         j        }t          |j        j                                      |j        j                            t          d                              	                    |j        j                  }| 
                    |g ddg di           d S )Nrf   r  r   r   rn   r   r?   r+   r   rU   r,   rI  rd   r
   r   rT   rN   r  s      r5   test_bound_in_scalar_bindparamz3ExpandingBoundInTest.test_bound_in_scalar_bindparam  s    &57:U579==30011Xegj!! 	
 	D"4"4"4c999=MNNNNNr7   c                    | j         j        }t          |j        j                                      |j        j                            g d                                        |j        j                  }| 	                    |g d           d S )Nr  r  
r?   r+   r   rU   r,   rI  rd   r
   rT   rN   r  s      r5   test_bound_in_scalar_directz0ExpandingBoundInTest.test_bound_in_scalar_direct  sw    &57:U579==++,,Xegj!! 	
 	D"4"4"455555r7   c                 ~   | j         j        }t          |j        j                                      |j        j                            ddg                                        |j        j                            g                     	                    |j        j                  }| 
                    |ddg           d S )Nr   r   rv   rw   r?   r+   r   rU   r,   rI  rd   r
   not_inrT   rN   r  s      r5   !test_nonempty_in_plus_empty_notinz6ExpandingBoundInTest.test_nonempty_in_plus_empty_notin  s    &57:U579==!Q(())U57:$$R(())Xegj!!	 	 	D4,/////r7   c                 z   | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                            ddg                    	                    |j        j                  }| 
                    |g            d S )Nr   r   r  r  s      r5   !test_empty_in_plus_notempty_notinz6ExpandingBoundInTest.test_empty_in_plus_notempty_notin  s    &57:U579==$$%%U57:$$aV,,--Xegj!!	 	 	D"%%%%%r7   c                     t          d                              t          dt          d                    }|                     |g ddg di           dS )	ztest related to #7292.

        as a type is given to the bound param, there is no ambiguity
        to the type of element.

        3select id FROM some_table WHERE z IN :q ORDER BY idrf   Ttype_r  r  r  r  r  r   N)r    
bindparamsr   r   rN   rK   r   s     r5   test_typed_str_inz&ExpandingBoundInTest.test_typed_str_in  sy     A
 

*Ys&DAAA
B
B 	 	+++, 	 	
 	
 	
 	
 	
r7   c                     t          d                              t          dd                    }|                     |g ddg di           dS )	ztest related to #7292.

        for untyped expression, we look at the types of elements.
        Test for Sequence to detect tuple in.  but not strings or bytes!
        as always....

        r  rf   Tr  r  r  r   Nr    r  r   rN   r  s     r5   test_untyped_str_inz(ExpandingBoundInTest.test_untyped_str_in  sw     A
 

*Ysd333
4
4 	 	+++, 	 	
 	
 	
 	
 	
r7   c                 p   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          d                                                  |j        j                  }|                     |g ddg di           d S )Nrf   r  r  r  )rn   r}   r   r  r  s      r5   !test_bound_in_two_tuple_bindparamz6ExpandingBoundInTest.test_bound_in_two_tuple_bindparam  s    &57:U6%')UWY//33IcNNCCDDXegj!! 	
 	$$$c3K3K3K-L 	 	
 	
 	
 	
 	
r7   c                 N   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    g d                    
                    |j        j                  }|                     |g d           d S )Nr  r  )r?   r+   r   rU   r,   rI  r"   rd   re   r
   rT   rN   r  s      r5   test_bound_in_two_tuple_directz3ExpandingBoundInTest.test_bound_in_two_tuple_direct	  s    &57:U6%')UWY//334L4L4LMMNNXegj!! 	
 	D"4"4"455555r7   c                 p   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    t          d                                                  |j        j                  }|                     |g ddg di           d S )Nrf   r  r  r   r  r  s      r5   /test_bound_in_heterogeneous_two_tuple_bindparamzDExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_bindparam  s    &57:U6%')UWY//33IcNNCCDDXegj!! 	
 	:::; 	 	
 	
 	
 	
 	
r7   c                 N   | j         j        }t          |j        j                                      t          |j        j        |j        j                  	                    g d                    
                    |j        j                  }|                     |g d           d S )Nr  r  )r?   r+   r   rU   r,   rI  r"   rd   r  r
   rT   rN   r  s      r5   ,test_bound_in_heterogeneous_two_tuple_directzAExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_direct!  s    &57:Uuwy%'),,00555  
 Xegj!! 	 		
 	
 	
 	
 	
r7   c                     t          d                              t          dd                    }|                     |g ddg di           d S )N8select id FROM some_table WHERE (x, z) IN :q ORDER BY idrf   Tr  r  r  r   r  r  s     r5   4test_bound_in_heterogeneous_two_tuple_text_bindparamzIExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam2  sw     F
 

*Ysd333
4
4 	 	:::; 	 	
 	
 	
 	
 	
r7   c                 `    G d dt           j                  }t          d                              t	          dt          t                      t                                d                    }|                     |g dd |dd	           |d
d           |dd          gi           d S )Nc                   &    e Zd Zd Zd Zd Zd ZdS )hExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuplec                     || _         d S rE   _datarK   r/   s     r5   __init__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__init__B      !


r7   c                 *    t          | j                  S rE   iterr  rK   s    r5   __iter__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__iter__E      DJ'''r7   c                     | j         |         S rE   r  rK   idxs     r5   __getitem__ztExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__getitem__H      z#&r7   c                 *    t          | j                  S rE   r   r  r  s    r5   __len__zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__len__K      4:&r7   NrZ   r[   r\   r	  r  r  r  r`   r7   r5   
LikeATupler  A  P        " " "( ( (' ' '' ' ' ' 'r7   r  r   rf   Tr  r  r   r  r   r  rn   r  r   )	collections_abcSequencer    r  r   r#   r   r   rN   rK   r  r   s      r5   ?test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuplezTExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple?  s    	' 	' 	' 	' 	'1 	' 	' 	' F
 

*9WYY99T  
 
 	 	Jq$''Jq$''Jq$'' 	 
	
 
	
 
	
 
	
 
	
r7   c                     G d dt           j                  }t          d                              t	          dd                    }|                     |g dd |dd	           |d
d           |dd          gi           d S )Nc                   &    e Zd Zd Zd Zd Zd ZdS )gExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuplec                     || _         d S rE   r  r  s     r5   r	  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__init__g  r
  r7   c                 *    t          | j                  S rE   r  r  s    r5   r  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__iter__j  r  r7   c                     | j         |         S rE   r  r  s     r5   r  zsExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__getitem__m  r  r7   c                 *    t          | j                  S rE   r  r  s    r5   r  zoExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__len__p  r  r7   Nr  r`   r7   r5   r  r#  f  r  r7   r  r   rf   Tr  r  r   r  r   r  rn   r  r   )r  r  r    r  r   rN   r  s      r5   >test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuplezSExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuplea  s    
	' 	' 	' 	' 	'1 	' 	' 	' F
 

*Ysd333
4
4 	 	Jq$''Jq$''Jq$'' 	 
	
 
	
 
	
 
	
 
	
r7   c                 8   | j         j        }t          |j        j                                      |j        j                            t          d                              	                    |j        j                  }| 
                    |g dg i           d S r  r  r  s      r5   (test_empty_set_against_integer_bindparamz=ExpandingBoundInTest.test_empty_set_against_integer_bindparam  {    &57:U579==30011Xegj!! 	
 	D"c2Y77777r7   c                    | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                  }| 	                    |g            d S rE   r  r  s      r5   %test_empty_set_against_integer_directz:ExpandingBoundInTest.test_empty_set_against_integer_direct  i    &egj!!''	b(9(9::CCEGJOOD"%%%%%r7   c                 <   | j         j        }t          |j        j                                      |j        j                            t          d                              	                    |j        j                  }| 
                    |g ddg i           d S Nrf   ru   rv   rw   rc  r   )r?   r+   r   rU   r,   rI  rd   r  r   rT   rN   r  s      r5   1test_empty_set_against_integer_negation_bindparamzFExpandingBoundInTest.test_empty_set_against_integer_negation_bindparam      &57:U579##IcNN3344Xegj!! 	
 	D":":":C9MMMMMr7   c                    | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                  }| 	                    |g d           d S Nr1  )
r?   r+   r   rU   r,   rI  rd   r  rT   rN   r  s      r5   .test_empty_set_against_integer_negation_directzCExpandingBoundInTest.test_empty_set_against_integer_negation_direct  w    &57:$$UWY%5%5b%9%9::CCEGJOO 	 	D":":":;;;;;r7   c                 8   | j         j        }t          |j        j                                      |j        j                            t          d                              	                    |j        j                  }| 
                    |g dg i           d S r  )r?   r+   r   rU   r,   rI  r  r
   r   rT   rN   r  s      r5   'test_empty_set_against_string_bindparamz<ExpandingBoundInTest.test_empty_set_against_string_bindparam  r+  r7   c                    | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                  }| 	                    |g            d S rE   )
r?   r+   r   rU   r,   rI  r  r
   rT   rN   r  s      r5   $test_empty_set_against_string_directz9ExpandingBoundInTest.test_empty_set_against_string_direct  r.  r7   c                 <   | j         j        }t          |j        j                                      |j        j                            t          d                              	                    |j        j                  }| 
                    |g ddg i           d S r0  )r?   r+   r   rU   r,   rI  r  r  r   rT   rN   r  s      r5   0test_empty_set_against_string_negation_bindparamzEExpandingBoundInTest.test_empty_set_against_string_negation_bindparam  r3  r7   c                    | j         j        }t          |j        j                                      |j        j                            g                                         |j        j                  }| 	                    |g d           d S r5  )
r?   r+   r   rU   r,   rI  r  r  rT   rN   r  s      r5   -test_empty_set_against_string_negation_directzBExpandingBoundInTest.test_empty_set_against_string_negation_direct  r7  r7   c           
      H   t          t          t                                          t	          dd                    t                      ft                                          }t          |                    |                                          d         d           d S )Nfoor`   )valueelse_r   Fr   )	r   r   r   r
   r   r!   r   r>   fetchonerK   rB   r   s      r5   )test_null_in_empty_set_is_false_bindparamz>ExpandingBoundInTest.test_null_in_empty_set_is_false_bindparam  s    FFJJyb999::FF gg  
 
 	Jt$$--//2J?????r7   c                 *   t          t          t                                          g           t	                      ft                                          }t          |                    |                                          d         d           d S )NrC  r   rE  )r   r   r   r
   r!   r   r>   rF  rG  s      r5   &test_null_in_empty_set_is_false_directz;ExpandingBoundInTest.test_null_in_empty_set_is_false_direct  s    FFJJrNNFF gg  
 
 	Jt$$--//2J?????r7   Nr+  ))rZ   r[   r\   r]   r^   r6   rC   rN   r  r  r   rR   tuple_in_w_emptyr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r(  r*  r-  r2  r6  r9  r;  r=  r?  rH  rJ  r`   r7   r5   r  r  J  s       K
 
 [
 	
 	
 [	
A A A A
A 
A 
A
& 
& 
& &8 8 '&8 &  '& &8 8 '&8 &  '&O O O6 6 60 0 0& & &
 
 
"
 
 
$ 	
 	
 	
 6 6 6 
 
 
 
 
 
  

 

 

 
 
 
B 
 
 
@8 8 8& & &
N N N< < <8 8 8& & &
N N N< < <
@ 
@ 
@
@ 
@ 
@ 
@ 
@r7   r  c                       e Zd ZdZdZdZed             Zed             Zd Z	d Z
ej        j        d             Zd	 Zej        j        d
             Zej        j        d             Zd Zd Zej        j        d             Zej        j        d             Zej        j        d             Zd Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j         ej        dh dfdh dfdh dfddhfd e  e!dd                     fd! e  e!dd                     fd" e             f          d#                         Z"dS )$LikeFunctionsTestTonceNc                     t          d|t          dt          d          t          dt          d                               d S )Nr+   r,   Tr-   r/   rg   r1   r2   s     r5   r6   zLikeFunctionsTest.define_tables  sI    4d33366"::&&		
 	
 	
 	
 	
r7   c                     |                     | j        j                                        ddddddddddd	dd
ddddddddddddddddddd dg           d S )Nr9   abcdefgr;   r   zab/cdefgr   zab%cdefgrn   ab_cdefgr}   zabcde/fgr   zabcde%fgr   zab#cdefg   ab9cdefg	   zabcde#fgr   abcd9fg   r=   rA   s     r5   rC   zLikeFunctionsTest.insert_data  s    J!((**),,*--*--*--*--*--*--*--*--9--4((	
 	
 	
 	
 	
r7   c                 <   | j         j        }t          j                                        5 }d |                    t          |j        j                  	                    |                    D             }d d d            n# 1 swxY w Y   t          ||           d S )Nc                     h | ]\  }|S r`   r`   )ra  rB  s     r5   	<setcomp>z*LikeFunctionsTest._test.<locals>.<setcomp>  s*       E   r7   )r?   r+   r   rG   rH   r>   r   rU   r,   rI  r	   )rK   r   r   r+   rM   rowss         r5   _testzLikeFunctionsTest._test  s    [+
Y   	D "ll6*,/+B+B+H+H+N+NOO  D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	D(s   A
BBBc                     | j         j        j        j        }|                     |                    d          h d           d S )Nab%c
   r9   r   r   rn   r}   r   r   rS  rU  r   r?   r+   rU   r/   r\  
startswithrK   cols     r5   test_startswith_unescapedz+LikeFunctionsTest.test_startswith_unescaped  s?    k$&+

3>>&))+J+J+JKKKKKr7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nr^  T
autoescaper   r`  rb  s     r5   test_startswith_autoescapez,LikeFunctionsTest.test_startswith_autoescape  s>    k$&+

3>>&T>::QC@@@@@r7   c                     | j         j        j        j        }|                     |                    t          d                    h d           d S )Nz'ab%c'r_  )r?   r+   rU   r/   r\  ra  r   rb  s     r5   test_startswith_sqlexprz)LikeFunctionsTest.test_startswith_sqlexpr  sR    k$&+

NN>(3344+++	
 	
 	
 	
 	
r7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nzab##c#escaper   r`  rb  s     r5   test_startswith_escapez(LikeFunctionsTest.test_startswith_escape  s>    k$&+

3>>'#>66<<<<<r7   c                     | j         j        j        j        }|                     |                    ddd          dh           |                     |                    ddd          dh           d S )Nr^  Trl  rg  rn  r   zab#cr   r`  rb  s     r5   !test_startswith_autoescape_escapez3LikeFunctionsTest.test_startswith_autoescape_escape  sh    k$&+

3>>&T#>FFLLL

3>>&T#>FFLLLLLr7   c                     | j         j        j        j        }|                     |                    d          h d           d S )Ne%fg	   r9   r   r   rn   r}   r   r   rS  rU  r?   r+   rU   r/   r\  endswithrb  s     r5   test_endswith_unescapedz)LikeFunctionsTest.test_endswith_unescaped  s?    k$&+

3<<'')D)D)DEEEEEr7   c                     | j         j        j        j        }|                     |                    t          d                    h d           d S )Nz'e%fg'ru  )r?   r+   rU   r/   r\  rw  r   rb  s     r5   test_endswith_sqlexprz'LikeFunctionsTest.test_endswith_sqlexpr#  sR    k$&+

LL11224O4O4O	
 	
 	
 	
 	
r7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nrt  Trf  r   rv  rb  s     r5   test_endswith_autoescapez*LikeFunctionsTest.test_endswith_autoescape)  s>    k$&+

3<<4<881#>>>>>r7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nze##fgrl  rm  rU  rv  rb  s     r5   test_endswith_escapez&LikeFunctionsTest.test_endswith_escape.  s>    k$&+

3<<<44qc:::::r7   c                     | j         j        j        j        }|                     |                    ddd          dh           |                     |                    ddd          dh           d S )Nrt  Trl  rq  r   ze#fgrU  rv  rb  s     r5   test_endswith_autoescape_escapez1LikeFunctionsTest.test_endswith_autoescape_escape3  h    k$&+

3<<4<DDqcJJJ

3<<4<DDqcJJJJJr7   c                     | j         j        j        j        }|                     |                    d          h d           d S )Nb%cderu  r?   r+   rU   r/   r\  containsrb  s     r5   test_contains_unescapedz)LikeFunctionsTest.test_contains_unescaped9  s?    k$&+

3<<((*E*E*EFFFFFr7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nr  Trf  r   r  rb  s     r5   test_contains_autoescapez*LikeFunctionsTest.test_contains_autoescape=  s>    k$&+

3<<D<99A3?????r7   c                     | j         j        j        j        }|                     |                    dd          dh           d S )Nzb##cderl  rm  r   r  rb  s     r5   test_contains_escapez&LikeFunctionsTest.test_contains_escapeB  s>    k$&+

3<<<55s;;;;;r7   c                     | j         j        j        j        }|                     |                    ddd          dh           |                     |                    ddd          dh           d S )Nzb%cdTrl  rq  r   zb#cdr   r  rb  s     r5   test_contains_autoescape_escapez1LikeFunctionsTest.test_contains_autoescape_escapeG  r  r7   c                     | j         j        j        j        }|                     |                    d           h d           d S )Na.cde>   r   r   rn   r   rS  r   r?   r+   rU   r/   r\  regexp_matchrb  s     r5   test_not_regexp_matchz'LikeFunctionsTest.test_not_regexp_matchM  sD    k$&+

C$$W---/B/B/BCCCCCr7   c                     | j         j        j        j        }|                     |                    dd                              d          h d           d S )Nr  FOO   r9   r}   r   rU  )r?   r+   rU   r/   r\  regexp_replacer  rb  s     r5   test_regexp_replacez%LikeFunctionsTest.test_regexp_replaceR  sY    k$&+

w..77>>	
 	
 	
 	
 	
r7   r  r  abc>   r9   r}   r   rU  r   z^abc9cderS  z^ar9   rW  z(b|c)z^(b|c)c                     | j         j        j        j        }|                     |                    |          |           d S rE   r  )rK   r    r   rc  s       r5   test_regexp_matchz#LikeFunctionsTest.test_regexp_matchY  s<     k$&+

3##D))844444r7   )#rZ   r[   r\   r]   run_insertsrun_deletesr^   r6   rC   r\  rd  r   rR   like_escapesrh  rj  ro  rr  rx  rz  r|  r~  r  r  r  r  r  r  r  r  r  r-  r   ranger  r`   r7   r5   rM  rM    s       KKK
 
 [
 
 
 [
$	 	 	L L L "A A #"A
 
 
 "= = #"= "M M #"M
F F F
 
 
 "? ? #"? "; ; #"; "K K #"K
G G G "@ @ #"@ "< < #"< "K K #"K
 "D D #"D $
 
 %$
 "W	,,,	   !	!!!"	!	ss55B<<  !	##eeArll##$	3355 5 5  #"5 5 5r7   rM  c                   N    e Zd ZdZdZed             Zed             Zd Zd Z	dS )ComputedColumnTestT)computed_columnsc                    t          d|t          dt          d          t          dt                    t          dt          t          d                    t          dt          t          d	                               d S )
Nsquarer,   Tr-   sideareazside * side	perimeterz4 * side)r   r   r   r   r2   s     r5   r6   z ComputedColumnTest.define_tablesl  sq    4d33367##67H]$;$;<<;*)=)=>>	
 	
 	
 	
 	
r7   c                 z    |                     | j        j                                        ddddddg           d S )Nr9   r   )r,   r  *   )r>   r?   r  r@   rA   s     r5   rC   zComputedColumnTest.insert_dataw  sP    J$$&&r""2r$:$:;	
 	
 	
 	
 	
r7   c                    t           j                                        5 }|                    t	          t          d                                        | j        j                  	                    | j        j        j
        j                                                            }t          |ddg           d d d            d S # 1 swxY w Y   d S )N*)r9   r   r0   r$  )r   r       )r   rG   rH   r>   r   r    rZ  r?   r  rT   rU   r,   rI   r	   rK   rM   ress      r5   test_select_allz"ComputedColumnTest.test_select_all~  s    Y   	>D,,tCyy!!T[/00$+,.122  hjj	 
 &(;<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   BCCCc                    t           j                                        5 }|                    t	          | j        j        j        j        | j        j        j        j	                  
                    | j        j                                      | j        j        j        j                                                            }t          |ddg           d d d            d S # 1 swxY w Y   d S )N)r0   r$  )r  r  )r   rG   rH   r>   r   r?   r  rU   r  r  rZ  rT   r,   rI   r	   r  s      r5   test_select_columnsz&ComputedColumnTest.test_select_columns  s   Y   	/D,,K&(-t{/A/C/M  T[/00$+,.122  hjj  i-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   B4C  C$'C$N)
rZ   r[   r\   r]   r   r^   r6   rC   r  r  r`   r7   r5   r  r  h  sp        K(L
 
 [
 
 
 [
> > >	/ 	/ 	/ 	/ 	/r7   r  c                       e Zd ZdZdZdZdZed             Zed             Z	d Z
d Zej        j        d             Zd	S )
IdentityColumnTestT)identity_columnsrN  c                 V   t          d|t          dt          t          dddd          d          t          dt	          d                               t          d	|t          dt          t          d
ddd          d          t          dt	          d                               d S )Ntbl_ar,   Tr  )alwaysstart
nominvalue
nomaxvaluer-   r   r0   tbl_br   i)	incrementr  minvaluemaxvaluer   r   r   r   r   r2   s     r5   r6   z IdentityColumnTest.define_tables  s    rdt   !   66#;;''	
 	
 	
 	2QKKK 	   66#;;''
	
 
	
 
	
 
	
 
	
r7   c                 R   |                     | j        j                                        ddiddig           |                     | j        j                                        ddiddig           |                     | j        j                                        dddg           d S )Nr   rS  rT  r  rU   r,   r   )r>   r?   r  r@   r  rA   s     r5   rC   zIdentityColumnTest.insert_data  s    J##%%c]VSM*	
 	
 	
 	J##%%c]VSM*	
 	
 	
 	J##%%$$%	
 	
 	
 	
 	
r7   c                 b   |                     t          t          d                                        | j        j                                      | j        j        j        j                            	                                }t          |ddg           |                     t          t          d                                        | j        j                                      | j        j        j        j                            	                                }t          |g d           d S )Nr  )r  rS  )+   rT  ))r  rT  )r   rS  )r  rU   )r>   r   r    rZ  r?   r  rT   rU   r,   rI   r	   r  rK   rB   r  s      r5   r  z"IdentityColumnTest.test_select_all  s      499[*++Xdk'),--
 
 (**	 	
 	C)Y'(((  499[*++Xdk'),--
 
 (**	 	
 	C11122222r7   c                    |                     t          | j        j        j        j                                      | j        j        j        j                                                            }t          |ddg           d S )N)r  )r  )	r>   r   r?   r  rU   r,   rT   rI   r	   r  s      r5   r  z&IdentityColumnTest.test_select_columns  sn      4;$&)**33DK4E4G4JKK
 

(** 	 	C%     r7   c                 N      fd}t          t          t          f|           d S )Nc                  t                          j        j                                        dddg           d S )N   rS  r  )r>   r?   r  r@   )rB   rK   s   r5   fnz7IdentityColumnTest.test_insert_always_error.<locals>.fn  sG    !((**S))*    r7   )r   r&   r'   )rK   rB   r  s   `` r5   test_insert_always_errorz+IdentityColumnTest.test_insert_always_error  s@    	 	 	 	 	 	 	}&67<<<<<r7   N)rZ   r[   r\   r]   r   r  r  r^   r6   rC   r  r  r   rR   identity_columns_standardr  r`   r7   r5   r  r    s        K(LKK
 
 [
4 
 
 [
3 3 3! ! ! /= = 0/= = =r7   r  c                   2    e Zd ZdZdZed             Zd ZdS )IdentityAutoincrementTestT)autoincrement_without_sequencec                     t          d|t          dt          t                      dd          t          dt	          d                               d S )Ntblr,   T)r.   autoincrementr   r0   r  r2   s     r5   r6   z'IdentityAutoincrementTest.define_tables  s^    

 "   66#;;''	
 	
 	
 	
 	
r7   c                    |                     | j        j                                        ddi          }|                     | j        j                                                                                  }t          |d           d S )Nr   row)r9   r  )r>   r?   r  r@   r   rD  r	   r  s      r5    test_autoincrement_with_identityz:IdentityAutoincrementTest.test_autoincrement_with_identity  sp      !7!7!9!9FE?KK  !7!7!9!9::@@BBCr7   N)rZ   r[   r\   r]   r   r^   r6   r  r`   r7   r5   r  r    sF        K6L
 
 [
    r7   r  c                   J    e Zd ZdZed             Zed             Zd Zd ZdS )
ExistsTestTc                     t          d|t          dt          d          t          dt          d                               d S )Nstuffr,   Tr-   r/   rg   r1   r2   s     r5   r6   zExistsTest.define_tables  sI    4d33366"::&&		
 	
 	
 	
 	
r7   c           	          |                     | j        j                                        ddddddddddddg           d S )Nr9   	some datar;   r   r   rn   zsome other data)r>   r?   r  r@   rA   s     r5   rC   zExistsTest.insert_data  sj    J##%%+..+..+.."344		
 	
 	
 	
 	
r7   c           
      >   | j         j        }t          |                    t	          t          d                                        t                                          |j        j	        dk                                  
                                dg           d S )Nr9   r  ru   r?   r  r	   r>   r   r   rI  r   rU   r/   rI   rK   rB   r  s      r5   test_select_existszExistsTest.test_select_exists  s    !wqzz""((HHNN57<;#>??   hjjF	
 	
 	
 	
 	
r7   c           
      <   | j         j        }t          |                    t	          t          d                                        t                                          |j        j	        dk                                  
                                g            d S )Nr9   zno datar  r  s      r5   test_select_exists_falsez#ExistsTest.test_select_exists_false  s    !wqzz""((HHNN57<9#<==   hjj	
 	
 	
 	
 	
r7   N)	rZ   r[   r\   r]   r^   r6   rC   r  r  r`   r7   r5   r  r    sk        K
 
 [
 	
 	
 [	
	
 	
 	
	
 	
 	
 	
 	
r7   r  c                   X    e Zd ZdZ ej        ej        j                  d             ZdS )DistinctOnTestTc                 *   t          d                              t          d                                        t	          d                    }t          j        d          5  |                     |d           d d d            d S # 1 swxY w Y   d S )Nr  rf   rA  z:DISTINCT ON is currently supported only by the PostgreSQL zSELECT DISTINCT * FROM foo)r   r  r   rZ  r   r   expect_deprecatedr  )rK   stms     r5   test_distinct_onzDistinctOnTest.test_distinct_on.  s    Skk""6#;;//;;E%LLII&H
 
 	C 	C %ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs   $BBBN)	rZ   r[   r\   r]   r   fails_ifrR   supports_distinct_onr  r`   r7   r5   r  r  +  sK        KWg&;<<C C =<C C Cr7   r  c            	       l    e Zd ZdZdZed             Z ej        dddddd	d
          d             Z	dS )IsOrIsNotDistinctFromTestT)supports_is_distinct_fromc                     t          d|t          dt          d          t          dt          d          t          dt          d                     d S )Nis_distinct_testr,   Tr-   col_ar;  col_br   r2   s     r5   r6   z'IsOrIsNotDistinctFromTest.define_tables;  sZ    4d3337Gd3337Gd333	
 	
 	
 	
 	
r7   )both_int_differentr   r9   r9   )both_int_samer9   r9   r   )one_null_firstNr9   r9   )one_null_secondr   Nr9   )	both_nullNNr   iaaaz3col_a_value, col_b_value, expected_row_count_for_is)id_r   c                    | j         j        }|                    |                                d||dg           |                    |                                                    |j        j                            |j        j	                                      
                                }t          t          |          |           |dk    rdnd}|                    |                                                    |j        j                            |j        j	                                      
                                }t          t          |          |           d S )Nr9   )r,   r  r  r   )r?   r  r>   r@   r   rI  rU   r  is_distinct_fromr  rI   r	   r   is_not_distinct_from)rK   col_a_valuecol_b_valueexpected_row_count_for_isrB   r  rL   expected_row_count_for_is_nots           r5   test_is_or_is_not_distinct_fromz9IsOrIsNotDistinctFromTest.test_is_or_is_not_distinct_fromE  sG    k*JJLLkBBC	
 	
 	

 ##JJLLsu{;;CEKHHII
 

(** 	 	KK%	
 	
 	
 +a//AAQ 	& ##JJLLsu{??LLMM
 

(** 	 	KK)	
 	
 	
 	
 	
r7   N)
rZ   r[   r\   r]   r   r^   r6   r   r-  r  r`   r7   r5   r  r  7  s~        K1L
 
 [
 W'"&'$F  
 
 
 
 
r7   r  c                   N    e Zd ZdZdZed             Zed             Zd Zd Z	dS )WindowFunctionTest)window_functionsTc           
          t          d|t          dt          d          t          dt                    t          dt                               d S )Nr+   r,   Tr-   col1col2r   r2   s     r5   r6   z WindowFunctionTest.define_tablesq  sP    4d33367##67##	
 	
 	
 	
 	
r7   c                     |                     | j        j                                        d t	          dd          D                        d S )Nc                      g | ]}|||d z  dS )r}   )r,   r  r  r`   ra  is     r5   rb  z2WindowFunctionTest.insert_data.<locals>.<listcomp>  s&    GGGQAq!a%00GGGr7   r9   rg   )r>   r?   r+   r@   r  rA   s     r5   rC   zWindowFunctionTest.insert_data{  sQ    J!((**GG%2,,GGG	
 	
 	
 	
 	
r7   c                    | j         j        }|                    t          t	          j        |j        j                                      |j        j	        
                                g                                        |j        j	        dk                                                         }t          |d t          d          D                        d S )N)rT   r  c                     g | ]}d S ))_   r`   r  s     r5   rb  z2WindowFunctionTest.test_window.<locals>.<listcomp>  s    ,,,Q5,,,r7      )r?   r+   r>   r   r   maxrU   r  overr  r   rI  r   r	   r  rK   rB   r+   r[  s       r5   test_windowzWindowFunctionTest.test_window  s    [+
!!*++00(l/44667 1    eJL%*++
 
 #%% 	 	D,,%)),,,-----r7   c           	      P   | j         j        }|                    t          t	          j        |j        j                                      |j        j	        gd                              
                                }t          |d t          ddd          D                        d S )N)r  r   )rT   r[  c                     g | ]}|fS r`   r`   r  s     r5   rb  z?WindowFunctionTest.test_window_rows_between.<locals>.<listcomp>  s    222AA4222r7   r}      )r?   r+   r>   r   r   r  rU   r  r  r  r   r	   r  r  s       r5   test_window_rows_betweenz+WindowFunctionTest.test_window_rows_between  s    [+
 !!*++00(l/0  1   
 
 #%% 	 	D22q#q!1!122233333r7   N)
rZ   r[   r\   r   r]   r^   r6   rC   r  r  r`   r7   r5   r  r  l  sp        (LK
 
 [
 
 
 [

. 
. 
.4 4 4 4 4r7   r  c                      e Zd ZdZdxZZd  ed          D             Zed             Z	ed             Z
 ej        d d  ed          D             ej        j        fd	  e ed                    ej        j        fd
  e edd                    ej        j        fd dgej        j        fd  e edd                    ej        j        fd  e edd                    ej        j        fd          d             ZdS )BitwiseTestTrN  c                     g | ]
}||d z   dS )r9   )rS  rT  r`   r  s     r5   rb  zBitwiseTest.<listcomp>  s$    ===a11q5))===r7   r   c           	      v    t          d|t          dt                    t          dt                               d S )NbitwiserS  rT  r   r2   s     r5   r6   zBitwiseTest.define_tables  s0    i6#w#7#7W9M9MNNNNNr7   c                 t    |                     | j        j                                        | j                   d S rE   )r>   r?   r  r@   inserted_datarA   s     r5   rC   zBitwiseTest.insert_data  s2    3:-44668IJJJJJr7   c                 ,    |                      d          S )Nr}   )bitwise_xorrS  s    r5   <lambda>zBitwiseTest.<lambda>      ammA&& r7   c                     g | ]
}|d k    |S r|   r`   r  s     r5   rb  zBitwiseTest.<listcomp>  s    ,,,1Q!VVQVVVr7   c                 ,    |                      d          S Nr9   )
bitwise_orr  s    r5   r   zBitwiseTest.<lambda>  s    all1oo r7   c                 ,    |                      d          S )Nrn   )bitwise_andr  s    r5   r   zBitwiseTest.<lambda>  r!  r7   rn   rS  c                 0    | dz
                                   S Nr   )bitwise_notr  s    r5   r   zBitwiseTest.<lambda>  s    q1u))++ r7   r   c                 ,    |                      d          S r$  )bitwise_lshiftr  s    r5   r   zBitwiseTest.<lambda>      a&&q)) r7   r9   c                 ,    |                      d          S r)  )bitwise_rshiftr  s    r5   r   zBitwiseTest.<lambda>  r-  r7   zcase, expectedr   c                      j         j        }|j        j        }t	          j        ||          }t          |                              |dk                                  |          }|	                    |          
                                                                }t          | fd|D                        d S )Nr  r   c                 *    g | ]}j         |         S r`   )r  )ra  r	  rK   s     r5   rb  z,BitwiseTest.test_bitwise.<locals>.<listcomp>  s!    :::A$$Q':::r7   )r?   r  rU   rS  r   resolve_lambdar   rI  rT   r>   mappingsr   r	   )	rK   r   r   rB   r  rS  opr   r  s	   `        r5   test_bitwisezBitwiseTest.test_bitwise  s    D k!EG#DA...c{{  a((11!44  &&//115577C:::::::;;;;;r7   N)rZ   r[   r\   r]   r  r  r  r  r^   r6   rC   r   r-  rR   supports_bitwise_xorlistsupports_bitwise_orsupports_bitwise_andsupports_bitwise_notsupports_bitwise_shiftr5  r`   r7   r5   r  r    s       K &&K+==5599===MO O [O K K [K W&&,,b		,,,1	
 &%DrOO0	
 '&Dq!1	
 ,+C1	
 *)Dq"3	
 *)Dq"3	

 "?     B
< 
<C   B
< 
< 
<r7   r  )@collections.abcr  r  rd  r  r   r   r   r   
assertionsr   r	   r
   	assertsqlr   r9  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   excr&   r'   
TablesTestr)   rb   TestBaser   r   r6  rO  ro  r  r  rM  r  r  r  r  r  r  r  r  r`   r7   r5   <module>rB     sF   * ) ) ) ) )     ! ! ! ! ! ! & & & & & &             & & & & & &             ! ! ! ! ! !                                                                                                                                                                   # # # # # ##
 #
 #
 #
 #
(% #
 #
 #
LJ< J< J< J< J<x* J< J< J<Z
 
 
 
 
8, 
 
 
 D8 D8 D8 D8 D88. D8 D8 D8N`
 `
 `
 `
 `
x2 `
 `
 `
FaP aP aP aP aPx" aP aP aPHt
 t
 t
 t
 t
, t
 t
 t
nN
 N
 N
 N
 N
/1DN
 N
 N
bJ@ J@ J@ J@ J@8. J@ J@ J@ZN5 N5 N5 N5 N5+ N5 N5 N5b(/ (/ (/ (/ (/, (/ (/ (/VM= M= M= M= M=, M= M= M=`     3   2,
 ,
 ,
 ,
 ,
$ ,
 ,
 ,
^	C 	C 	C 	C 	C')< 	C 	C 	C2
 2
 2
 2
 2
 3 2
 2
 2
j04 04 04 04 04, 04 04 04f9< 9< 9< 9< 9<(% 9< 9< 9< 9< 9<r7   