
    +h                     D   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( dd'l'm)Z) dd(l%m*Z*  G d) d*ejV                        Z, G d+ d,ejV                        Z- G d- d.ej\                        Z/ G d/ d0ejV                        Z0 G d1 d2ejV                        Z1 G d3 d4ejV                        Z2 G d5 d6eeejV                        Z3 G d7 d8ejV                        Z4 G d9 d:ejV                        Z5 G d; d<ejV                        Z6 G d= d>ejV                        Z7 G d? d@ejV                        Z8 G dA dBejV                        Z9 G dC dDeejV                        Z: G dE dFejV                        Z;y)G    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)util)values)DatabaseError)ProgrammingError)collections_abcc                   n    e Zd ZdZed        Zed        Zd Zej                  j                  d        Zy)CollateTestTc                 f    t        d|t        dt        d      t        dt        d                   y )N
some_tableidTprimary_keydatad   r   r   r   r   clsmetadatas     W/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/testing/suite/test_select.pydefine_tableszCollateTest.define_tables-   s*    4d366#;'		
    c                 |    |j                  | j                  j                  j                         ddddddg       y )N   collate data1r.   r1   r   collate data2executetablesr-   insertr5   
connections     r7   insert_datazCollateTest.insert_data6   s;    JJ!!((*/2/2	
r9   c                     t         j                  j                         5 }t        |j	                  |      j                         |       d d d        y # 1 sw Y   y xY wNr   dbconnectr	   r@   fetchallselfr   resultconns       r7   _assert_resultzCollateTest._assert_result@   E    YY  	9DV$--/8	9 	9 	9   *AAc                 h   t         j                  j                  t         j                        }| j	                  t        | j                  j                        j                  | j                  j                  j                  j                  j                  |      j                               ddg       y )N)r;   r<   )r   r>   )r   requiresget_order_by_collationr   rP   r   rA   r-   order_bycr1   collateasc)rM   	collations     r7   test_collate_order_byz!CollateTest.test_collate_order_byD   s    $$;;GNNK	4;;))*33&&((--55i@DDF "#78		
r9   N)__name__
__module____qualname____backend__classmethodr8   rE   rP   r   rT   order_by_collationr[    r9   r7   r+   r+   *   sR    K
 
 
 
9 ((
 )
r9   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y)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                   y )
Nr-   r.   Tr/   xyq2   pr3   r4   s     r7   r8   zOrderByLabelTest.define_tables[   sL    4d33 3 3r
#3r
#	
r9   c                     |j                  | j                  j                  j                         ddddddddddddddd	d
ddg       y )Nr;   r   q1p3)r.   rf   rg   rh   rj   r   q2p2   q3p1r?   rC   s     r7   rE   zOrderByLabelTest.insert_datag   sU    JJ!!((*qqt$?qqt$?qqt$?	
r9   c                     t         j                  j                         5 }t        |j	                  |      j                         |       d d d        y # 1 sw Y   y xY wrG   rH   rL   s       r7   rP   zOrderByLabelTest._assert_resultr   rQ   rR   c                     | j                   j                  }|j                  j                  j	                  d      }| j                  t        |      j                  |      g d       y )Nlxr;   r   r   )rA   r-   rW   rf   labelrP   r   rV   rM   r   ru   s      r7   
test_plainzOrderByLabelTest.test_plainv   sG    &&WWYY__T"F2J//35GHr9   c                     | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }| j                  t        |      j                  |      g d       y )Nru   )ry         )	rA   r-   rW   rf   rg   rz   rP   r   rV   r{   s      r7   test_composed_intz"OrderByLabelTest.test_composed_int{   sV    &&ggii%''))#**40F2J//35GHr9   c           	      >   | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }t        j                  |j                  j                        |j                  j                  z   j                  d      }| j                  t        ||      j                  ||j                               dt        j                  d      fdt        j                  d      fdt        j                  d      fg       y )	Nru   lyr   q1p3r   q2p2r   q3p1)rA   r-   rW   rf   rg   rz   r   lowerrh   rj   rP   r   rV   descr%   u)rM   r   ru   r   s       r7   test_composed_multiplez'OrderByLabelTest.test_composed_multiple   s    &&ggii%''))#**40jj#eggii/66t<2rN##B	2 1dffVn"5466&>7JK	
r9   c                     | j                   j                  }|j                  j                  j	                  d      }| j                  t        |      j                  |j                               g d       y )Nru   )ry   rx   rw   )	rA   r-   rW   rf   rz   rP   r   rV   r   r{   s      r7   test_plain_descz OrderByLabelTest.test_plain_desc   sM    &&WWYY__T"F2J//	:<NOr9   c                    | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }| j                  t        |      j                  |j                               g d       y )Nru   )r   r~   ry   )
rA   r-   rW   rf   rg   rz   rP   r   rV   r   r{   s      r7   test_composed_int_descz'OrderByLabelTest.test_composed_int_desc   s\    &&ggii%''))#**40F2J//	:<NOr9   c                 r   | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }t        t        j                  |j                  j                        |      j                  |      j                  |      }| j                  |g d       y )Nru   ))r;   r   )r;   r   )r;   r   )rA   r-   rW   rf   rg   rz   r   r   countr.   group_byrV   rP   )rM   r   exprstmts       r7   test_group_by_composedz'OrderByLabelTest.test_group_by_composed   s    &&		EGGII%,,T24::eggjj)4099$?HHN 	 	D":;r9   N)r\   r]   r^   __doc__r_   r`   r8   rE   rP   r|   r   r   r   r   r   rT   group_by_complex_expressionr   rb   r9   r7   rd   rd   P   sv     K	
 	
 
 
9I
I

P
P
 11< 2<r9   rd   c                       e Zd ZdZdZd Zy)ValuesExpressionTest)table_value_constructorTc                     t        t        dt              t        dt              d      j	                  g d      }t        |j                  t        |            j                         g d       y )Nr.   name	my_values)r   ))r;   name1)r   name2)r   name3)	r&   r   r   r   r1   r	   r@   r   all)rM   rD   
value_exprs      r7   test_tuplesz ValuesExpressionTest.test_tuples   sX    4!6&&#9

$9
: 	 	vj126686	
r9   N)r\   r]   r^   __requires__r_   r   rb   r9   r7   r   r      s    /LK
r9   r   c                   b   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                  j2                  d        Zej                  j2                  d        Zej                  j2                  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                  jD                  d               Z#ej                  j<                  d        Z$ej                  j<                  d        Z%ej                  jL                  d        Z'ej                  jL                  ej                  jP                  d                Z)ej                  jL                  ej                  jP                  d!               Z*ej                  jV                  d"        Z,ej                  jV                  ej                  jP                  d#               Z-ej                  jL                  ej                  jV                  d$               Z.ej                  jL                  ej                  jV                  ej                  jP                  d%                      Z/y&))FetchLimitOffsetTestTc           
      z    t        d|t        dt        d      t        dt              t        dt                     y Nr-   r.   Tr/   rf   rg   r   r   r   r4   s     r7   r8   z"FetchLimitOffsetTest.define_tables   0    4d33 3 	
r9   c                     |j                  | j                  j                  j                         ddddddddddddddddddddg       y )Nr;   r   r.   rf   rg   r   rp   r      r?   rC   s     r7   rE   z FetchLimitOffsetTest.insert_data   s]    JJ!!((*qq)qq)qq)qq)qq)		
r9   c                    |r]|j                  ||      j                         }t        t        |      t        |             t        t	        |      t	        |             y t        |j                  ||      j                         |       y rG   )r@   rK   r	   lenset)rM   rD   r   rN   paramsset_	query_ress          r7   rP   z#FetchLimitOffsetTest._assert_result   sh     "**66:CCEIIF,IF, 
""662;;=vFr9   c                     t         j                  j                  d      }t        |j	                  ||      j                         |       y )NT)close_with_result)r   rI   rJ   r	   exec_driver_sqlrK   rM   r   rN   r   rO   s        r7   _assert_result_strz'FetchLimitOffsetTest._assert_result_str   s9    yy  4 8D  099;VDr9   c                    | j                   j                  }t        |      j                  |j                  j
                        }| j                  ||j                  d      ddg       | j                  ||j                  d      g d       y Nr   r;   r;   r   r   r   r   r   r   r   r   r   rp   )rA   r-   r   rV   rW   r.   rP   limit)rM   rD   r   r   s       r7   test_simple_limitz&FetchLimitOffsetTest.test_simple_limit   sr    &&e}%%eggjj1JJqM	"	

 	JJqM-	
r9   c                 D   | j                   j                  }t        |j                  j                        j                  d      j                         }t        t        |      t        |            j                         j                         }| j                  ||dg       y )Nr;   rw   )
rA   r-   r   rW   r.   r   scalar_subqueryr$   subqueryrP   )rM   rD   r   r   r   s        r7    test_limit_render_multiple_timesz5FetchLimitOffsetTest.test_limit_render_multiple_times   sy    &&eggjj!''*::<&,t-668??A	
r9   c                 p   | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  d      ddg       | j                  |t        |      j	                  |j
                  j                        j                  d      g d       y r   rA   r-   rP   r   rV   rW   r.   fetchrM   rD   r   s      r7   test_simple_fetchz&FetchLimitOffsetTest.test_simple_fetch   s    &&5M""577::.44Q7	"	

 	5M""577::.44Q7-	
r9   c                 p   | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  d      g d       | j                  |t        |      j	                  |j
                  j                        j                  d      ddg       y )Nr   r   rp   rp   r   r   rp   r   r   r   r   rA   r-   rP   r   rV   rW   r.   offsetr   s      r7   test_simple_offsetz'FetchLimitOffsetTest.test_simple_offset   s    &&5M""577::.55a8-	

 	5M""577::.55a8	"	
r9   )r   r   r   r;   r   r   )r   r   r   )r   r;   r   r   cases)argnamesc                 :   | j                   j                  }|j                  i       }g d}|D ]j  \  }}||||z    }| j                  |t	        |      j                  |j                  j                        j                  |      j                  |      |       l y )N)compiled_cacher   r   r   r   r   )
rA   r-   execution_optionsrP   r   rV   rW   r.   r   r   )rM   rD   r   r   assert_datar   r   expecteds           r7   test_simple_limit_offsetz-FetchLimitOffsetTest.test_simple_limit_offset  s     &&111D
M" 	ME6"6FUN;Hu&&uwwzz288?FFvN	r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  d      j                  d      ddg       | j                  |t        |      j	                  |j
                  j                        j                  d      j                  d      g d       y )Nr   r;   r   r   r   r   	rA   r-   rP   r   rV   rW   r.   r   r   r   s      r7   test_simple_fetch_offsetz-FetchLimitOffsetTest.test_simple_fetch_offset#  s    &&5M""577::.44Q7>>qA	"	
 	5M""577::.44Q7>>qA-	
r9   c                     | j                   j                  }| j                  |t        |      j	                  d      g dd       y )N
   r   Tr   )rA   r-   rP   r   r   r   s      r7   test_fetch_offset_no_orderz/FetchLimitOffsetTest.test_fetch_offset_no_order2  s?    &&5M#C	 	 	
r9   c                 p   | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  d      g d       | j                  |t        |      j	                  |j
                  j                        j                  d      g d       y )Nr   r   r;   r   r   r   r   r   r   s      r7   test_simple_offset_zeroz,FetchLimitOffsetTest.test_simple_offset_zero<  s    &&5M""577::.55a8C	
 	5M""577::.55a88	
r9   c                 `   | j                   j                  }t        |      j                  |j                  j
                        j                  d      j                  d      }|j                  t        j                  j                  ddi      }t        |      }| j                  |ddg       y	z7test that 'literal binds' mode works - no bound params.r   r;   literal_bindsT)dialectcompile_kwargsr   r   N)rA   r-   r   rV   rW   r.   r   r   compiler   rI   r   strr   rM   r   r   sqls       r7   test_limit_offset_nobindsz.FetchLimitOffsetTest.test_limit_offset_nobindsK       &&e}%%eggjj177:AA!DllII%%6M  
 #hi%;<r9   c                 `   | j                   j                  }t        |      j                  |j                  j
                        j                  d      j                  d      }|j                  t        j                  j                  ddi      }t        |      }| j                  |ddg       yr   )rA   r-   r   rV   rW   r.   r   r   r   r   rI   r   r   r   r   s       r7   test_fetch_offset_nobindsz.FetchLimitOffsetTest.test_fetch_offset_nobindsX  r   r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d            ddgddi       | j                  |t        |      j	                  |j
                  j                        j                  t        d            g dddi       y )Nlr   r   r   r   r   r   )	rA   r-   rP   r   rV   rW   r.   r   r   r   s      r7   test_bound_limitz%FetchLimitOffsetTest.test_bound_limite  s    &&5M""577::.44Ys^D	"8	 	 	
 	5M""577::.44Ys^D-8	 	 	
r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d            g dddi       | j                  |t        |      j	                  |j
                  j                        j                  t        d            g dddi       y )Nor   r   r   r   r;   )	rA   r-   rP   r   rV   rW   r.   r   r   r   s      r7   test_bound_offsetz&FetchLimitOffsetTest.test_bound_offsetv  s    &&5M""577::.55inE-8	 	 	
 	5M""577::.55inE88	 	 	
r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d            j                  t        d            ddgddd       | j                  |t        |      j	                  |j
                  j                        j                  t        d            j                  t        d            g d	d
dd       y )Nr   r   r   r   r   r;   )r   r   r   r   r   )
rA   r-   rP   r   rV   rW   r.   r   r   r   r   s      r7   test_bound_limit_offsetz,FetchLimitOffsetTest.test_bound_limit_offset      &&5MXeggjj!U9S>"VIcN#	"# 	 	
 	5MXeggjj!U9S>"VIcN#-# 	 	
r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d            j                  t        d            ddgddd       | j                  |t        |      j	                  |j
                  j                        j                  t        d            j                  t        d            g d	d
dd       y )Nfr   r   r   r   r;   )r   r   r   r   r   )
rA   r-   rP   r   rV   rW   r.   r   r   r   r   s      r7   test_bound_fetch_offsetz,FetchLimitOffsetTest.test_bound_fetch_offset  r   r9   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         ddg       y )N12r   r   )	rA   r-   rP   r   rV   rW   r.   r   r   r   s      r7   test_expr_offsetz%FetchLimitOffsetTest.test_expr_offset  s\    &&5MXeggjj!VN3'.*==>	"	
r9   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         g d       y )Nr  r  r   )	rA   r-   rP   r   rV   rW   r.   r   r   r   s      r7   test_expr_limitz$FetchLimitOffsetTest.test_expr_limit  sW    &&5MXeggjj!U>#&)<<=-	
r9   c           	      B   | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         j                  t        d      t        d      z         ddg       y Nr  r   r   
rA   r-   rP   r   rV   rW   r.   r   r   r   r   s      r7   test_expr_limit_offsetz+FetchLimitOffsetTest.test_expr_limit_offset  su    &&5MXeggjj!U>#&)<<=VN3'.*==>	"	
r9   c           	      B   | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         j                  t        d      t        d      z         ddg       y r	  )
rA   r-   rP   r   rV   rW   r.   r   r   r   r   s      r7   test_expr_fetch_offsetz+FetchLimitOffsetTest.test_expr_fetch_offset  sw     &&5MXeggjj!U>#&)<<=VN3'.*==>	"	
r9   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  d      j                  t        d      t        d      z         ddg       | j                  |t        |      j	                  |j
                  j                        j                  d      j                  t        d      t        d      z         g d       y )Nr   r  r   r   r   r   )
rA   r-   rP   r   rV   rW   r.   r   r   r   r   s      r7   test_simple_limit_expr_offsetz2FetchLimitOffsetTest.test_simple_limit_expr_offset  s    &&5MXeggjj!U1XVN3'.*==>	"	
 	5MXeggjj!U1XVN3'.*==>-	
r9   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         j                  d      ddg       | j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         j                  d      ddg       y )Nr  r   r   r   r;   r   r
  r   s      r7   test_expr_limit_simple_offsetz2FetchLimitOffsetTest.test_expr_limit_simple_offset  s    &&5MXeggjj!U>#&)<<=VAY	"	
 	5MXeggjj!U>#&)<<=VAY	"	
r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                  j                               j                  dd      ddgd       | j                  |t        |      j	                  |j
                  j                  j                               j                  dd      g dd       y )	Nr;   T	with_tiesr   r   r   r   r   	rA   r-   rP   r   rV   rW   rf   r   r   r   s      r7   test_simple_fetch_tiesz+FetchLimitOffsetTest.test_simple_fetch_ties  s    &&5M""57799>>#34::1:M	"	 	 	
 	5M""57799>>#34::1:M-	 	 	
r9   c                 d   | j                   j                  }|j                  t        |      j	                  |j
                  j                        j                  dd      j                  d            j                         }t        |d   d       t        t        |      t        g d             y )Nr   Tr  r   r   r   rA   r-   r@   r   rV   rW   rf   r   r   rK   r	   r   rM   rD   r   fas       r7   test_fetch_offset_tiesz+FetchLimitOffsetTest.test_fetch_offset_ties  s     &&5MXeggii U1U%VAY	

 (* 	 	BqE9CGS:;<r9   c                    | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  dd      j                  d      ddg       | j                  |t        |      j	                  |j
                  j                        j                  dd      j                  d      dd	g       y )
Nr   Tr  r;   r   r   r   r   r   )	rA   r-   rP   r   rV   rW   rf   r   r   r   s      r7   #test_fetch_offset_ties_exact_numberz8FetchLimitOffsetTest.test_fetch_offset_ties_exact_number,  s     &&5MXeggii U1U%VAY	"	
 	5MXeggii U1U%VAY	"	
r9   c                     | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  dd      dg       y )N   Tpercentr   r   r   s      r7   test_simple_fetch_percentz.FetchLimitOffsetTest.test_simple_fetch_percentB  sQ    &&5M""577::.44R4FK	
r9   c                     | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  dd      j                  d      ddg       y )N(   Tr   r;   r   r   r   r   s      r7   test_fetch_offset_percentz.FetchLimitOffsetTest.test_fetch_offset_percentK  s\     &&5MXeggjj!U2tU$VAY	"	
r9   c                     | j                   j                  }| j                  |t        |      j	                  |j
                  j                  j                               j                  ddd      ddgd       y )Nr  Tr!  r  r   r   r   r  r   s      r7   test_simple_fetch_percent_tiesz3FetchLimitOffsetTest.test_simple_fetch_percent_tiesX  sd     &&5MXeggiinn&'U2ttU4	" 	 	
r9   c                 f   | j                   j                  }|j                  t        |      j	                  |j
                  j                        j                  ddd      j                  d            j                         }t        |d   d       t        t        |      t        g d             y )Nr$  Tr'  r   r   r   r   r  r  s       r7   test_fetch_offset_percent_tiesz3FetchLimitOffsetTest.test_fetch_offset_percent_tiese  s     &&5MXeggii U2ttU4VAY	

 (* 	 	BqE9CGS:;<r9   N)rb   Frb   )0r\   r]   r^   r_   r`   r8   rE   rP   r   r   r   r   rT   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*  rb   r9   r7   r   r      s   K
 
 

 

 ;@	GE

 !!
 "
 
 
 W	!	!	!	   !!
 "
 ''
 (
 
 
 
= 
= !!
= "
= ((
 )
  ((
 )
  ((
 )
, !!
 "
, 11
 2
 11
 2
 11	
 2	
 !!&&	
 ' "	
 11
 2
( 11
 2
(   
 !
    //	= 0 !	=   //
 0 !
( ##
 $
 ##//	
 0 $	
   ##	
 $ !	
   ##//	= 0 $ !	=r9   r   c                   V    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y
)JoinTestTc                     t         j                  j                         5 }t        |j	                  ||      j                         |       d d d        y # 1 sw Y   y xY wrG   rH   r   s        r7   rP   zJoinTest._assert_resultw  K    YY  	ADVV,557@	A 	A 	A   +AAc                     t        d|t        dt        d             t        d|t        dt        d      t        dt        d      d	             y )
Nar.   Tr/   ba_idza.idFnullable)r   r   r   r   r4   s     r7   r8   zJoinTest.define_tables{  sB    c8VD'tDE4d36:f->		
r9   c           	         |j                  | j                  j                  j                         ddiddiddiddiddig       |j                  | j                  j                  j                         ddddddddddddg       y )Nr.   r;   r   r   rp   r   )r.   r=  )r@   rA   r;  rB   r<  rC   s     r7   rE   zJoinTest.insert_data  s    JJLL!AYq	D!9tQi$C	

 	JJLL!!$!$!$!$		
r9   c                    | j                  dd      \  }}t        ||      j                  |j                  |            j	                  |j
                  j                  |j
                  j                        }| j                  |g d       y Nr;  r<  ))r;   r;   r;   )r;   r   r;   )r   rp   r   )r   r   r   rA   r   select_fromjoinrV   rW   r.   rP   rM   r;  r<  r   s       r7   test_inner_join_fkzJoinTest.test_inner_join_fk  b    {{3$1a|''q	2;;ACCFFACCFFKD"NOr9   c                    | j                  dd      \  }}t        ||      j                  |j                  |t	                           j                  |j                  j                  |j                  j                        }| j                  |t        j                  g dg d      D cg c]  \  \  }\  }}|||f c}}}       y c c}}}w )Nr;  r<  )rw   rx   ry   rp   r~   ))r;   r;   r   )rp   r   )r   r   )rA   r   rD  rE  r!   rV   rW   r.   rP   	itertoolsproduct)rM   r;  r<  r   rW   s        r7   test_inner_join_truezJoinTest.test_inner_join_true  s    {{3$1 1aL[46*+Xaccffaccff% 	 	 %.$5$524%  DQ&1a Aq			
s   +C	c                 (   | j                  dd      \  }}t        ||      j                  |j                  |t	                           j                  |j                  j                  |j                  j                        }| j                  |g        y )Nr;  r<  )	rA   r   rD  rE  r   rV   rW   r.   rP   rF  s       r7   test_inner_join_falsezJoinTest.test_inner_join_false  sk    {{3$1 1aL[57+,Xaccffaccff% 	 	D"%r9   c                 ,   | j                  dd      \  }}t        ||      j                  |j                  |t	                           j                  |j                  j                  |j                  j                        }| j                  |g d       y )Nr;  r<  ))r;   NN)r   NN)r   NN)rp   NN)r   NN)	rA   r   rD  	outerjoinr   rV   rW   r.   rP   rF  s       r7   test_outer_join_falsezJoinTest.test_outer_join_false  sq    {{3$1 1aL[Q01Xaccffaccff% 	 			
r9   c                    | j                  dd      \  }}t        ||      j                  |j                  |            j	                  |j
                  j                  |j
                  j                        }| j                  |g d       y rB  rC  rF  s       r7   test_outer_join_fkzJoinTest.test_outer_join_fk  rH  r9   Nr+  )r\   r]   r^   r_   rP   r`   r8   rE   rG  rM  rO  rR  rT  rb   r9   r7   r6  r6  t  sP    KA 
 
 
 
 P
(	&
(Pr9   r6  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y)CompoundSelectTestTc           
      z    t        d|t        dt        d      t        dt              t        dt                     y r   r   r4   s     r7   r8   z CompoundSelectTest.define_tables  r   r9   c           
          |j                  | j                  j                  j                         ddddddddddddddddg       y )Nr;   r   r   r   rp   r   r?   rC   s     r7   rE   zCompoundSelectTest.insert_data  sS    JJ!!((*qq)qq)qq)qq)		
r9   c                     t         j                  j                         5 }t        |j	                  ||      j                         |       d d d        y # 1 sw Y   y xY wrG   rH   r   s        r7   rP   z!CompoundSelectTest._assert_result  r8  r9  c                 z   | j                   j                  }t        |      j                  |j                  j
                  dk(        }t        |      j                  |j                  j
                  dk(        }t        ||      }| j                  |j                  |j                  j
                        ddg       y Nr   r   r   r   )
rA   r-   r   whererW   r.   r$   rP   rV   selected_columnsrM   r   s1s2u1s        r7   test_plain_unionz#CompoundSelectTest.test_plain_union  s    &&E]  q1E]  q12r]KK++../)Y1G	
r9   c                    | j                   j                  }t        |      j                  |j                  j
                  dk(        }t        |      j                  |j                  j
                  dk(        }t        ||      j                         j                         }| j                  |j                  |j                  j
                        ddg       y r[  )rA   r-   r   r\  rW   r.   r$   aliasrP   rV   r]  r^  s        r7   test_select_from_plain_unionz/CompoundSelectTest.test_select_from_plain_union  s    &&E]  q1E]  q12r]  "))+KK++../)Y1G	
r9   c                 `   | j                   j                  }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        }t        ||      j                  d      }| j                  |j                  |j                  j
                        ddg       y Nr   r;   r   r   r   )rA   r-   r   r\  rW   r.   r   rV   r$   rP   r]  r^  s        r7   &test_limit_offset_selectable_in_unionsz9CompoundSelectTest.test_limit_offset_selectable_in_unions	  s     &&E]  q177:CCEGGJJOE]  q177:CCEGGJJO2r]  #KK++../)Y1G	
r9   c                 $   | j                   j                  }t        |      j                  |j                  j
                  dk(        j                  |j                  j
                        }t        |      j                  |j                  j
                  dk(        j                  |j                  j
                        }t        ||      j                  d      }| j                  |j                  |j                  j
                        ddg       y r[  )rA   r-   r   r\  rW   r.   rV   r$   r   rP   r]  r^  s        r7   "test_order_by_selectable_in_unionsz5CompoundSelectTest.test_order_by_selectable_in_unions  s    &&E]  q1::577::FE]  q1::577::F2r]  #KK++../)Y1G	
r9   c                    | j                   j                  }t        |      j                  |j                  j
                  dk(        j                         }t        |      j                  |j                  j
                  dk(        j                         }t        ||      j                  d      }| j                  |j                  |j                  j
                        ddg       y r[  )rA   r-   r   r\  rW   r.   distinctr$   r   rP   rV   r]  r^  s        r7   "test_distinct_selectable_in_unionsz5CompoundSelectTest.test_distinct_selectable_in_unions   s    &&E]  q1::<E]  q1::<2r]  #KK++../)Y1G	
r9   c                    | j                   j                  }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        }t        ||      j                         }| j                  |j                         j                  d      j                  |j                  j
                        ddg       y rg  )rA   r-   r   r\  rW   r.   r   rV   r$   rd  rP   r^  s        r7   &test_limit_offset_in_unions_from_aliasz9CompoundSelectTest.test_limit_offset_in_unions_from_alias*  s    &&E]  q177:CCEGGJJOE]  q177:CCEGGJJO 2r]  "IIKa ))"$$''2Y	4J	
r9   c                    | j                   j                  }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        j                         j                         }t        |      j                  |j                  j
                  dk(        j                  d      j                  |j                  j
                        j                         j                         }t        ||      j                  d      }| j                  |j                  |j                  j
                        ddg       y rg  )rA   r-   r   r\  rW   r.   r   rV   rd  r$   rP   r]  r^  s        r7   .test_limit_offset_aliased_selectable_in_unionszACompoundSelectTest.test_limit_offset_aliased_selectable_in_unions6  s    &&5MU577::?#U1XXeggjj!UWVX 	 5MU577::?#U1XXeggjj!UWVX 	 2r]  #KK++../)Y1G	
r9   Nr+  )r\   r]   r^   r_   r`   r8   rE   rP   rb  re  r   rT   order_by_col_from_union/parens_in_union_contained_select_w_limit_offsetrh  0parens_in_union_contained_select_wo_limit_offsetrj  rm  ro  rq  rb   r9   r7   rV  rV    s    K
 
 	
 	
A

 --EE
 F .
 FF
 G

 EE	
 F	

r9   rV  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y)PostCompileParamsTestT)standard_cursor_sqlc                     t        d|t        dt        d      t        dt              t        dt              t        dt        d                   y 	Nr-   r.   Tr/   rf   rg   zri   r3   r4   s     r7   r8   z#PostCompileParamsTest.define_tablesV  >    4d33 3 3r
#	
r9   c                     |j                  | j                  j                  j                         dddddddddddddddddd	d
dg       y Nr;   r   z1)r.   rf   rg   rz  r   z2rp   z3r   z4r?   rC   s     r7   rE   z!PostCompileParamsTest.insert_dataa  [    JJ!!((*qqt4qqt4qqt4qqt4		
r9   c                     | j                   j                  }t        |j                  j                        j                  |j                  j                  t        dd      k(        }| j                  |di        y )Nrh   Tliteral_executezKSELECT some_table.id FROM some_table WHERE some_table.x = __[POSTCOMPILE_q]	rA   r-   r   rW   r.   r\  rf   r   assert_compilerM   r   r   s      r7   test_compilez"PostCompileParamsTest.test_compilem  s`    &&eggjj!''GGII3==
 	5		
r9   c                     | j                   j                  }t        |j                  j                        j                  |j                  j                  t        ddd      k(        }| j                  |di d       y )Nrh   r   Tr  z<SELECT some_table.id FROM some_table WHERE some_table.x = 10)r   r  r  s      r7   test_compile_literal_bindsz0PostCompileParamsTest.test_compile_literal_binds{  sh    &&eggjj!''GGII3DAA
 	J	 	 	
r9   c                 L   | j                   j                  }t        |j                  j                        j                  |j                  j                  t        dd      k(        }| j                         5 }t        j                  j                         5 }|j                  |t        d             d d d        d d d        j                  t        dt        j                  j                   j"                  rd             y i              y # 1 sw Y   \xY w# 1 sw Y   `xY w)Nrh   Tr  r   rh   z>SELECT some_table.id 
FROM some_table 
WHERE some_table.x = 10rb   )rA   r-   r   rW   r.   r\  rf   r   sql_execution_asserterr   rI   rJ   r@   dictassert_r   r   
positionalrM   r   r   asserterrO   s        r7   test_executez"PostCompileParamsTest.test_execute  s    &&eggjj!''GGII3==
 ((* 	/h""$ /T4":./	/ 	,ii''22	
 9;	
/ /	/ 	/s$   7DD3DD	DD#c           	      j   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        ddd                  }| j                         5 }t        j                  j                         5 }|j                  |t        g d             d d d        d d d        j                  t!        dt        j                  j"                  j$                  rd             y i              y # 1 sw Y   \xY w# 1 sw Y   `xY w)Nrh   T	expandingr  )r   r   r   r  zFSELECT some_table.id 
FROM some_table 
WHERE some_table.x IN (5, 6, 7)rb   )rA   r-   r   rW   r.   r\  rf   r
   r   r  r   rI   rJ   r@   r  r  r   r   r  r  s        r7   +test_execute_expanding_plus_literal_executezAPostCompileParamsTest.test_execute_expanding_plus_literal_execute  s    &&eggjj!''GGIIMM)C4NO
 ((* 	6h""$ 6T4)#456	6 	4ii''22	
 9;	
6 6	6 	6s$   D)#DD)D&	"D))D2c           	         | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        ddd                  }| j                         5 }t        j                  j                         5 }|j                  |t!        ddg             d d d        d d d        j#                  t%        dt        j                  j&                  j(                  rdnd	z  t        j                  j&                  j*                  rd
             y i              y # 1 sw Y   xY w# 1 sw Y   xY w)Nrh   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  rb   )rA   r-   r   rW   r.   r\  r"   rf   rg   r
   r   r  r   rI   rJ   r@   r  r  r   r   tuple_in_valuesr  r  s        r7   1test_execute_tuple_expanding_plus_literal_executezGPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_execute  s-   &&eggjj!''57799eggii(,,#tD
 ((* 	@h""$ @T47H*=#>?@	@ 	+ !'		 1 1 A A9rK ii''22	
 9;	
@ @	@ 	@$   "E0E$ E0$E-	)E00E9c           	         | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        ddd                  }| j                         5 }t        j                  j                         5 }|j                  |t!        ddg             d d d        d d d        j#                  t%        dt        j                  j&                  j(                  rdnd	z  t        j                  j&                  j*                  rd
             y i              y # 1 sw Y   xY w# 1 sw Y   xY w)Nrh   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  rb   )rA   r-   r   rW   r.   r\  r"   rf   rz  r
   r   r  r   rI   rJ   r@   r  r  r   r   r  r  r  s        r7   ?test_execute_tuple_expanding_plus_literal_heterogeneous_executezUPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_heterogeneous_execute  s-   &&eggjj!''57799eggii(,,#tD
 ((* 	Dh""$ DT49j*A#BCD	D 	/ !'		 1 1 A A9rK ii''22	
 9;	
D D	D 	Dr  N)r\   r]   r^   r_   r   r`   r8   rE   r  r  r  r  r   rT   tuple_inr  r  rb   r9   r7   rv  rv  O  s     K+L
 
 	
 	



&
& 
 
. 
 
r9   rv  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(y")$ExpandingBoundInTestTc                     t        d|t        dt        d      t        dt              t        dt              t        dt        d                   y ry  r3   r4   s     r7   r8   z"ExpandingBoundInTest.define_tables  r{  r9   c                     |j                  | j                  j                  j                         dddddddddddddddddd	d
dg       y r}  r?   rC   s     r7   rE   z ExpandingBoundInTest.insert_data  r  r9   c                     t         j                  j                         5 }t        |j	                  ||      j                         |       d d d        y # 1 sw Y   y xY wrG   rH   r   s        r7   rP   z#ExpandingBoundInTest._assert_result  r8  r9  c                    | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g g g d       y )Nrh   rj   )rh   rj   r   )rA   r-   r   rW   r.   r\  rf   r
   r   rg   rV   rP   r  s      r7   "test_multiple_empty_sets_bindparamz7ExpandingBoundInTest.test_multiple_empty_sets_bindparam  s     &&577::U57799==301U57799==301Xeggjj!	 	 	D"2B-?@r9   c                    | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rG   )rA   r-   r   rW   r.   r\  rf   r
   rg   rV   rP   r  s      r7   test_multiple_empty_sets_directz4ExpandingBoundInTest.test_multiple_empty_sets_direct
  s     &&577::U57799==$%U57799==$%Xeggjj!	 	 	D"%r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        d                  j                  |j                  j                        }| j                  |g dg i       y Nrh   r   rA   r-   r   rW   r.   r\  r"   rf   rz  r
   r   rV   rP   r  s      r7   )test_empty_heterogeneous_tuples_bindparamz>ExpandingBoundInTest.test_empty_heterogeneous_tuples_bindparam      &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	D"c2Y7r9   c                 ~      j                   j                   fd} |g g         |g dg d        |g g        y )Nc                 N   t        j                  j                        j                  t	        j                  j
                  j                  j                        j                  |             j                  j                  j                        }j                  ||       y rG   )
r   rW   r.   r\  r"   rf   rz  r
   rV   rP   valr   r   rM   r   s      r7   gozGExpandingBoundInTest.test_empty_heterogeneous_tuples_direct.<locals>.go$  h    uwwzz"veggii377<=%''**% 
 h/r9   )r   r  )r   r  )rp   r  rx   ry   rJ  rA   r-   rM   r  r   s   ` @r7   &test_empty_heterogeneous_tuples_directz;ExpandingBoundInTest.test_empty_heterogeneous_tuples_direct   s7    &&	0 	2r

,.@A
2r
r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        d                  j                  |j                  j                        }| j                  |g dg i       y r  rA   r-   r   rW   r.   r\  r"   rf   rg   r
   r   rV   rP   r  s      r7   'test_empty_homogeneous_tuples_bindparamz<ExpandingBoundInTest.test_empty_homogeneous_tuples_bindparam0  r  r9   c                 ~      j                   j                   fd} |g g         |g dg d        |g g        y )Nc                 N   t        j                  j                        j                  t	        j                  j
                  j                  j                        j                  |             j                  j                  j                        }j                  ||       y rG   )
r   rW   r.   r\  r"   rf   rg   r
   rV   rP   r  s      r7   r  zEExpandingBoundInTest.test_empty_homogeneous_tuples_direct.<locals>.go>  r  r9   ))r;   r   r   r   r   rp   rv   r  r  s   ` @r7   $test_empty_homogeneous_tuples_directz9ExpandingBoundInTest.test_empty_homogeneous_tuples_direct:  s7    &&	0 	2r

#%78
2r
r9   c                 ^   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg di       y )Nrh   r  r   r   rp   r   rA   r-   r   rW   r.   r\  rf   r
   r   rV   rP   r  s      r7   test_bound_in_scalar_bindparamz3ExpandingBoundInTest.test_bound_in_scalar_bindparamJ  st    &&577::U57799==301Xeggjj! 	
 	D"4c9=MNr9   c                 D   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  
rA   r-   r   rW   r.   r\  rf   r
   rV   rP   r  s      r7   test_bound_in_scalar_directz0ExpandingBoundInTest.test_bound_in_scalar_directS  sf    &&577::U57799==+,Xeggjj! 	
 	D"45r9   c                    | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  ddg            j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |ddg       y )Nr   r   rx   ry   rA   r-   r   rW   r.   r\  rf   r
   not_inrV   rP   r  s      r7   !test_nonempty_in_plus_empty_notinz6ExpandingBoundInTest.test_nonempty_in_plus_empty_notin\  s    &&577::U57799==!Q()U577::$$R()Xeggjj!	 	 	D4,/r9   c                    | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                  j                  ddg            j                  |j                  j                        }| j                  |g        y )Nr   r   r  r  s      r7   !test_empty_in_plus_notempty_notinz6ExpandingBoundInTest.test_empty_in_plus_notempty_notinf  s    &&577::U57799==$%U577::$$aV,-Xeggjj!	 	 	D"%r9   c                     t        d      j                  t        dt        d            }| j	                  |g ddg di       y)	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 idrh   Ttype_r  r  r  r  r  r   N)r    
bindparamsr   r   rP   rM   r   s     r7   test_typed_str_inz&ExpandingBoundInTest.test_typed_str_inp  sK     A

*Ys&DA
B 	 	+, 	 	
r9   c                     t        d      j                  t        dd            }| j                  |g ddg di       y)	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  rh   Tr  r  r  r   Nr    r  r   rP   r  s     r7   test_untyped_str_inz(ExpandingBoundInTest.test_untyped_str_in  sI     A

*Ysd3
4 	 	+, 	 	
r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        d                  j                  |j                  j                        }| j                  |g ddg di       y )Nrh   r  r  r  )rp   r   r   r  r  s      r7   !test_bound_in_two_tuple_bindparamz6ExpandingBoundInTest.test_bound_in_two_tuple_bindparam  s    &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	$c3K-L 	 	
r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  )rA   r-   r   rW   r.   r\  r"   rf   rg   r
   rV   rP   r  s      r7   test_bound_in_two_tuple_directz3ExpandingBoundInTest.test_bound_in_two_tuple_direct  sx    &&577::U6%''))UWWYY/334LMNXeggjj! 	
 	D"45r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        d                  j                  |j                  j                        }| j                  |g ddg di       y )Nrh   r  r  r   r  r  s      r7   /test_bound_in_heterogeneous_two_tuple_bindparamzDExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_bindparam  s    &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	:; 	 	
r9   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  )rA   r-   r   rW   r.   r\  r"   rf   rz  r
   rV   rP   r  s      r7   ,test_bound_in_heterogeneous_two_tuple_directzAExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_direct  s    &&577::Uuwwyy%'')),005
 Xeggjj! 	 		
r9   c                     t        d      j                  t        dd            }| j                  |g ddg di       y )N8select id FROM some_table WHERE (x, z) IN :q ORDER BY idrh   Tr  r  r  r   r  r  s     r7   4test_bound_in_heterogeneous_two_tuple_text_bindparamzIExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam  sI     F

*Ysd3
4 	 	:; 	 	
r9   c                     G d dt         j                        }t        d      j                  t	        dt        t               t                     d            }| j                  |g dd |dd	       |d
d       |dd      gi       y )Nc                   $    e Zd Zd Zd Zd Zd Zy)hExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuplec                     || _         y rG   _datarM   r1   s     r7   __init__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__init__  	    !
r9   c                 ,    t        | j                        S rG   iterr  rM   s    r7   __iter__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__iter__      DJJ''r9   c                      | j                   |   S rG   r  rM   idxs     r7   __getitem__ztExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__getitem__      zz#&r9   c                 ,    t        | j                        S rG   r   r  r  s    r7   __len__zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__len__      4::&r9   Nr\   r]   r^   r  r  r  r   rb   r9   r7   
LikeATupler        "(''r9   r  r  rh   Tr  r  r   r  r   r  rp   r  r   )	r)   Sequencer    r  r   r#   r   r   rP   rM   r  r   s      r7   ?test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuplezTExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple  s    	'11 	' F

*9WY9T
 	 	q$'q$'q$' 	 
	
r9   c                      G d dt         j                        }t        d      j                  t	        dd            }| j                  |g dd |dd	       |d
d       |dd      gi       y )Nc                   $    e Zd Zd Zd Zd Zd Zy)gExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuplec                     || _         y rG   r  r  s     r7   r  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__init__  r  r9   c                 ,    t        | j                        S rG   r  r  s    r7   r  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__iter__   r  r9   c                      | j                   |   S rG   r  r  s     r7   r  zsExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__getitem__  r  r9   c                 ,    t        | j                        S rG   r  r  s    r7   r   zoExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__len__  r  r9   Nr  rb   r9   r7   r  r
    r  r9   r  r  rh   Tr  r  r   r  r   r  rp   r  r   )r)   r  r    r  r   rP   r  s      r7   >test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuplezSExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple  s}    
	'11 	' F

*Ysd3
4 	 	q$'q$'q$' 	 
	
r9   c                 V   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g dg i       y r  r  r  s      r7   (test_empty_set_against_integer_bindparamz=ExpandingBoundInTest.test_empty_set_against_integer_bindparam  r    &&577::U57799==301Xeggjj! 	
 	D"c2Y7r9   c                 <   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rG   r  r  s      r7   %test_empty_set_against_integer_directz:ExpandingBoundInTest.test_empty_set_against_integer_direct!  b    &&eggjj!''		b(9:CCEGGJJOD"%r9   c                 Z   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg i       y Nrh   rw   rx   ry   rJ  r   )rA   r-   r   rW   r.   r\  rf   r  r   rV   rP   r  s      r7   1test_empty_set_against_integer_negation_bindparamzFExpandingBoundInTest.test_empty_set_against_integer_negation_bindparam&  u    &&577::U57799##IcN34Xeggjj! 	
 	D":C9Mr9   c                 @   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g d       y Nr  )
rA   r-   r   rW   r.   r\  rf   r  rV   rP   r  s      r7   .test_empty_set_against_integer_negation_directzCExpandingBoundInTest.test_empty_set_against_integer_negation_direct/  j    &&577::$$UWWYY%5%5b%9:CCEGGJJO 	 	D":;r9   c                 V   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g dg i       y r  )rA   r-   r   rW   r.   r\  rz  r
   r   rV   rP   r  s      r7   'test_empty_set_against_string_bindparamz<ExpandingBoundInTest.test_empty_set_against_string_bindparam6  r  r9   c                 <   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rG   )
rA   r-   r   rW   r.   r\  rz  r
   rV   rP   r  s      r7   $test_empty_set_against_string_directz9ExpandingBoundInTest.test_empty_set_against_string_direct?  r  r9   c                 Z   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg i       y r  )rA   r-   r   rW   r.   r\  rz  r  r   rV   rP   r  s      r7   0test_empty_set_against_string_negation_bindparamzEExpandingBoundInTest.test_empty_set_against_string_negation_bindparamD  r  r9   c                 @   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g d       y r  )
rA   r-   r   rW   r.   r\  rz  r  rV   rP   r  s      r7   -test_empty_set_against_string_negation_directzBExpandingBoundInTest.test_empty_set_against_string_negation_directM  r  r9   c           
          t        t        t               j                  t	        dd            t               ft                           }t        |j                  |      j                         d   d       y )Nfoorb   )valueelse_r   Fr   )	r   r   r   r
   r   r!   r   r@   fetchonerM   rD   r   s      r7   )test_null_in_empty_set_is_false_bindparamz>ExpandingBoundInTest.test_null_in_empty_set_is_false_bindparamT  s_    FJJyb9:F g
 	Jt$--/2J?r9   c                     t        t        t               j                  g       t	               ft                           }t        |j                  |      j                         d   d       y )Nr*  r   r,  )r   r   r   r
   r!   r   r@   r-  r.  s      r7   &test_null_in_empty_set_is_false_directz;ExpandingBoundInTest.test_null_in_empty_set_is_false_direct`  sW    FJJrNF g
 	Jt$--/2J?r9   Nr+  ))r\   r]   r^   r_   r`   r8   rE   rP   r  r  r   rT   tuple_in_w_emptyr  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&  r/  r1  rb   r9   r7   r  r    s   K
 
 	
 	
A
A
& &&8 '8 && ' &&8 '8 && 'O60&
"
$ 	
 	
 6 6 
 
 
 
  

 

 
 
B 
 
@8&
N<8&
N<
@
@r9   r  c                      e Zd 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d Zd Zd Zd Zd Zd Zd Zd Zd Zej2                  j4                  d        Zej2                  j8                  d        Zej2                  j4                   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!y)$LikeFunctionsTestTonceNc                 f    t        d|t        dt        d      t        dt        d                   y )Nr-   r.   Tr/   r1   ri   r3   r4   s     r7   r8   zLikeFunctionsTest.define_tabless  s*    4d366":&		
r9   c                     |j                  | j                  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       y )Nr;   abcdefgr=   r   zab/cdefgr   zab%cdefgrp   ab_cdefgr   zabcde/fgr   zabcde%fgr   zab#cdefg   ab9cdefg	   zabcde#fgr   abcd9fg   r?   rC   s     r7   rE   zLikeFunctionsTest.insert_data|  s    JJ!!((*),*-*-*-*-*-*-*-*-9-4(	
r9   c                 P   | j                   j                  }t        j                  j	                         5 }|j                  t        |j                  j                        j                  |            D ch c]  \  }| }}d d d        t        |       y c c}w # 1 sw Y   xY wrG   )rA   r-   r   rI   rJ   r@   r   rW   r.   r\  r	   )rM   r   r   r-   rO   r)  rowss          r7   _testzLikeFunctionsTest._test  s    [[++
YY  	D #ll6*,,//+B+H+H+NOE D 	 	D(	 	s   A B5B BBB%c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Nab%c
   r;   r   r   rp   r   r   r   r:  r<  r   rA   r-   rW   r1   rA  
startswithrM   cols     r7   test_startswith_unescapedz+LikeFunctionsTest.test_startswith_unescaped  s5    kk$$&&++

3>>&)+JKr9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )NrC  T
autoescaper   rE  rG  s     r7   test_startswith_autoescapez,LikeFunctionsTest.test_startswith_autoescape  s:    kk$$&&++

3>>&T>:QC@r9   c                     | j                   j                  j                  j                  }| j	                  |j                  t        d            h d       y )Nz'ab%c'rD  )rA   r-   rW   r1   rA  rF  r   rG  s     r7   test_startswith_sqlexprz)LikeFunctionsTest.test_startswith_sqlexpr  s=    kk$$&&++

NN>(34+	
r9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nzab##c#escaper   rE  rG  s     r7   test_startswith_escapez(LikeFunctionsTest.test_startswith_escape  s:    kk$$&&++

3>>'#>6<r9   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )NrC  TrQ  rL  rS  r   zab#cr   rE  rG  s     r7   !test_startswith_autoescape_escapez3LikeFunctionsTest.test_startswith_autoescape_escape  s[    kk$$&&++

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

3>>&T#>FLr9   c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Ne%fg	   r;   r   r   rp   r   r   r   r:  r<  rA   r-   rW   r1   rA  endswithrG  s     r7   test_endswith_unescapedz)LikeFunctionsTest.test_endswith_unescaped  s5    kk$$&&++

3<<')DEr9   c                     | j                   j                  j                  j                  }| j	                  |j                  t        d            h d       y )Nz'e%fg'rZ  )rA   r-   rW   r1   rA  r\  r   rG  s     r7   test_endswith_sqlexprz'LikeFunctionsTest.test_endswith_sqlexpr  s=    kk$$&&++

LL124O	
r9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )NrY  TrK  r   r[  rG  s     r7   test_endswith_autoescapez*LikeFunctionsTest.test_endswith_autoescape  s:    kk$$&&++

3<<4<81#>r9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nze##fgrQ  rR  r<  r[  rG  s     r7   test_endswith_escapez&LikeFunctionsTest.test_endswith_escape  s:    kk$$&&++

3<<<4qc:r9   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )NrY  TrQ  rV  r   ze#fgr<  r[  rG  s     r7   test_endswith_autoescape_escapez1LikeFunctionsTest.test_endswith_autoescape_escape  [    kk$$&&++

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

3<<4<DqcJr9   c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Nb%cderZ  rA   r-   rW   r1   rA  containsrG  s     r7   test_contains_unescapedz)LikeFunctionsTest.test_contains_unescaped  s5    kk$$&&++

3<<(*EFr9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nrh  TrK  r   ri  rG  s     r7   test_contains_autoescapez*LikeFunctionsTest.test_contains_autoescape  s:    kk$$&&++

3<<D<9A3?r9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nzb##cderQ  rR  r   ri  rG  s     r7   test_contains_escapez&LikeFunctionsTest.test_contains_escape  s:    kk$$&&++

3<<<5s;r9   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )Nzb%cdTrQ  rV  r   zb#cdr   ri  rG  s     r7   test_contains_autoescape_escapez1LikeFunctionsTest.test_contains_autoescape_escape  rf  r9   c                     | j                   j                  j                  j                  }| j	                  |j                  d       h d       y )Na.cde>   r   r   rp   r   r:  r   rA   r-   rW   r1   rA  regexp_matchrG  s     r7   test_not_regexp_matchz'LikeFunctionsTest.test_not_regexp_match  s:    kk$$&&++

C$$W--/BCr9   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      j                  d      h d       y )Nrs  FOO   r;   r   r   r<  )rA   r-   rW   r1   rA  regexp_replacerj  rG  s     r7   test_regexp_replacez%LikeFunctionsTest.test_regexp_replace  sF    kk$$&&++

w.77>	
r9   rs  ry  abc>   r;   r   r   r<  r   z^abc9cder:  z^ar;   r>  z(b|c)z^(b|c)c                     | j                   j                  j                  j                  }| j	                  |j                  |      |       y rG   rt  )rM   r    r   rH  s       r7   test_regexp_matchz#LikeFunctionsTest.test_regexp_match  s8     kk$$&&++

3##D)84r9   )"r\   r]   r^   r_   run_insertsrun_deletesr`   r8   rE   rA  rI  rM  rO  rT  rW  r]  r_  ra  rc  re  rk  rm  ro  rq  r   rT   ru  rv  rz  r{  r-  r   ranger  rb   r9   r7   r4  r4  m  sT   KKK
 
 
 
$	LA
=M
F
?;K
G@<K
 ""D #D $$
 %
 ""W	,	 !	!"	!	s5B< !	#eArl#$	355 #5r9   r4  c                   @    e Zd ZdZdZed        Zed        Zd Zd Z	y)ComputedColumnTestT)computed_columnsc                     t        d|t        dt        d      t        dt              t        dt        t        d            t        dt        t        d	                   y )
Nsquarer.   Tr/   sideareazside * side	perimeterz4 * side)r   r   r   r   r4   s     r7   r8   z ComputedColumnTest.define_tables  sH    4d367#67H]$;<;*)=>	
r9   c                 |    |j                  | j                  j                  j                         ddddddg       y )Nr;   r   )r.   r  *   )r@   rA   r  rB   rC   s     r7   rE   zComputedColumnTest.insert_data  s8    JJ$$&r"2r$:;	
r9   c                    t         j                  j                         5 }|j                  t	        t        d            j                  | j                  j                        j                  | j                  j                  j                  j                              j                         }t        |ddg       d d d        y # 1 sw Y   y xY w)N*)r;   r   r2   r$  )r   r       )r   rI   rJ   r@   r   r    rD  rA   r  rV   rW   r.   rK   r	   rM   rO   ress      r7   test_select_allz"ComputedColumnTest.test_select_all  s    YY  	>D,,tCy!T[[//0$++,,..112 hj	 
 &(;<=	> 	> 	>s   BCCc                 ,   t         j                  j                         5 }|j                  t	        | j
                  j                  j                  j                  | j
                  j                  j                  j                        j                  | j
                  j                        j                  | j
                  j                  j                  j                              j                         }t        |ddg       d d d        y # 1 sw Y   y xY w)N)r2   r$  )r  r  )r   rI   rJ   r@   r   rA   r  rW   r  r  rD  rV   r.   rK   r	   r  s      r7   test_select_columnsz&ComputedColumnTest.test_select_columns  s    YY  	/D,,KK&&((--t{{/A/A/C/C/M/M T[[//0$++,,..112 hj  i-.	/ 	/ 	/s   C"D

DN)
r\   r]   r^   r_   r   r`   r8   rE   r  r  rb   r9   r7   r  r    s<    K(L
 
 
 
>	/r9   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y	)
IdentityColumnTestT)identity_columnsr5  c                     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                   y )Ntbl_ar.   Tr  )alwaysstart
nominvalue
nomaxvaluer/   r   r2   tbl_br   i)	incrementr  minvaluemaxvaluer   r   r   r   r   r4   s     r7   r8   z IdentityColumnTest.define_tables&  s    rdt ! 66#;'	
 	2QK 	 66#;'
	
r9   c                 \   |j                  | j                  j                  j                         ddiddig       |j                  | j                  j                  j                         ddiddig       |j                  | j                  j                  j                         dddg       y )Nr   r;  r<  r  rW   r.   r   )r@   rA   r  rB   r  rC   s     r7   rE   zIdentityColumnTest.insert_dataA  s    JJ##%c]VSM*	
 	JJ##%c]VSM*	
 	JJ##%$%	
r9   c                 h   |j                  t        t        d            j                  | j                  j
                        j                  | j                  j
                  j                  j                              j                         }t        |ddg       |j                  t        t        d            j                  | j                  j                        j                  | j                  j                  j                  j                              j                         }t        |g d       y )Nr  )r  r;  )+   r<  ))r  r<  )r   r;  )r  rW   )r@   r   r    rD  rA   r  rV   rW   r.   rK   r	   r  rM   rD   r  s      r7   r  z"IdentityColumnTest.test_select_allP  s      49[**+Xdkk'')),,-
 (*	 	
 	C)Y'(  49[**+Xdkk'')),,-
 (*	 	
 	C12r9   c                 .   |j                  t        | j                  j                  j                  j
                        j                  | j                  j                  j                  j
                              j                         }t        |ddg       y )N)r  )r  )	r@   r   rA   r  rW   r.   rV   rK   r	   r  s      r7   r  z&IdentityColumnTest.test_select_columns_  sk      4;;$$&&))*33DKK4E4E4G4G4J4JK

(* 	 	C% r9   c                 @      fd}t        t        t        f|       y )Nc                  v     j                  j                  j                  j                         dddg       y )N   r;  r  )r@   rA   r  rB   )rD   rM   s   r7   fnz7IdentityColumnTest.test_insert_always_error.<locals>.fnh  s2    !!((*S)*r9   )r   r'   r(   )rM   rD   r  s   `` r7   test_insert_always_errorz+IdentityColumnTest.test_insert_always_errorf  s    	 	}&67<r9   N)r\   r]   r^   r_   r   r  r  r`   r8   rE   r  r  r   rT   identity_columns_standardr  rb   r9   r7   r  r     sf    K(LKK
 
4 
 
3! //= 0=r9   r  c                   *    e Zd ZdZdZed        Zd Zy)IdentityAutoincrementTestT)autoincrement_without_sequencec                 z    t        d|t        dt        t               dd      t        dt	        d                   y )Ntblr.   T)r0   autoincrementr   r2   r  r4   s     r7   r8   z'IdentityAutoincrementTest.define_tablesu  s9    
 " 66#;'	
r9   c                 
   |j                  | j                  j                  j                         ddi      }|j                  | j                  j                  j	                               j                         }t        |d       y )Nr   row)r;   r  )r@   rA   r  rB   r   firstr	   r  s      r7    test_autoincrement_with_identityz:IdentityAutoincrementTest.test_autoincrement_with_identity  s]      !7!7!9FE?K  !7!7!9:@@BCr9   N)r\   r]   r^   r_   r   r`   r8   r  rb   r9   r7   r  r  q  s#    K6L
 
r9   r  c                   <    e Zd ZdZed        Zed        Zd Zd Zy)
ExistsTestTc                 f    t        d|t        dt        d      t        dt        d                   y )Nstuffr.   Tr/   r1   ri   r3   r4   s     r7   r8   zExistsTest.define_tables  s*    4d366":&		
r9   c           	          |j                  | j                  j                  j                         ddddddddddddg       y )Nr;   	some datar=   r   r   rp   zsome other data)r@   rA   r  rB   rC   s     r7   rE   zExistsTest.insert_data  sL    JJ##%+.+.+."34		
r9   c           
      "   | j                   j                  }t        |j                  t	        t        d            j                  t               j                  |j                  j                  dk(                    j                         dg       y )Nr;   r  rw   rA   r  r	   r@   r   r   r\  r   rW   r1   rK   rM   rD   r  s      r7   test_select_existszExistsTest.test_select_exists  sg    !!wqz"((HNN577<<;#>? hjF	
r9   c           
          | j                   j                  }t        |j                  t	        t        d            j                  t               j                  |j                  j                  dk(                    j                         g        y )Nr;   zno datar  r  s      r7   test_select_exists_falsez#ExistsTest.test_select_exists_false  se    !!wqz"((HNN577<<9#<= hj	
r9   N)	r\   r]   r^   r_   r`   r8   rE   r  r  rb   r9   r7   r  r    s7    K
 
 	
 	
	
	
r9   r  c                   h    e Zd ZdZ ej
                  ej                  j                        d        Zy)DistinctOnTestTc                     t        d      j                  t        d            j                  t	        d            }t        j                  d      5  | j                  |d       d d d        y # 1 sw Y   y xY w)Nr  rh   r(  z:DISTINCT ON is currently supported only by the PostgreSQL zSELECT DISTINCT * FROM foo)r   rl  r   rD  r   r   expect_deprecatedr  )rM   stms     r7   test_distinct_onzDistinctOnTest.test_distinct_on  sf    Sk""6#;/;;E%LI&&H
 	C %AB	C 	C 	Cs   A--A6N)	r\   r]   r^   r_   r   fails_ifrT   supports_distinct_onr  rb   r9   r7   r  r    s4    KWg&&;;<C =Cr9   r  c            	       b    e Zd ZdZdZed        Z ej                  dddddd	d
      d        Z	y)IsOrIsNotDistinctFromTestT)supports_is_distinct_fromc                     t        d|t        dt        d      t        dt        d      t        dt        d             y )Nis_distinct_testr.   Tr/   col_ar>  col_br   r4   s     r7   r8   z'IsOrIsNotDistinctFromTest.define_tables  s4    4d37Gd37Gd3	
r9   )both_int_differentr   r;   r;   )both_int_samer;   r;   r   )one_null_firstNr;   r;   )one_null_secondr   Nr;   )	both_nullNNr   iaaaz3col_a_value, col_b_value, expected_row_count_for_is)id_r   c                    | j                   j                  }|j                  |j                         d||dg       |j                  |j	                         j                  |j                  j                  j                  |j                  j                                    j                         }t        t        |      |       |dk(  rdnd}|j                  |j	                         j                  |j                  j                  j                  |j                  j                                    j                         }t        t        |      |       y )Nr;   )r.   r  r  r   )rA   r  r@   rB   r   r\  rW   r  is_distinct_fromr  rK   r	   r   is_not_distinct_from)rM   col_a_valuecol_b_valueexpected_row_count_for_isrD   r  rN   expected_row_count_for_is_nots           r7   test_is_or_is_not_distinct_fromz9IsOrIsNotDistinctFromTest.test_is_or_is_not_distinct_from  s    kk**JJLkBC	

 ##JJLsuu{{;;CEEKKHI

(* 	 	K%	
 +a/AQ 	& ##JJLsuu{{??LM

(* 	 	K)	
r9   N)
r\   r]   r^   r_   r   r`   r8   r   r-  r  rb   r9   r7   r  r    sT    K1L
 
 W'"&'$F

r9   r  )<rK  r  r   r   r   r   
assertionsr   r	   r
   	assertsqlr   schemar   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(   r)   
TablesTestr+   rd   TestBaser   r   r6  rV  rv  r  r4  r  r  r  r  r  r  rb   r9   r7   <module>r     s    ! &   &   !                             # ##
(%% #
LJ<x** J<Z
8,, 
 D=8.. D=NaPx"" aPHt
,, t
nN
/1D1DN
bJ@8.. J@ZE5++ E5P(/,, (/VN=,, N=b 3 3 2,
$$ ,
^	C')<)< 	C2
 3 3 2
r9   