
    h7                        d dl mZ d dlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ dd	l	mZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# dd lm$Z$ dd!lm%Z% dd"lm&Z& dd#lm'Z' dd$lm(Z( dd%l)m*Z* dd&l)m+Z+  G d' d(ejX                        Z- G d) d*ejX                        Z. G d+ d,ej^                        Z0 G d- d.ejX                        Z1 G d/ d0ejX                        Z2 G d1 d2ejX                        Z3 G d3 d4ejX                        Z4 G d5 d6eeejX                        Z5 G d7 d8ejX                        Z6 G d9 d:ejX                        Z7 G d; d<ejX                        Z8 G d= d>ejX                        Z9 G d? d@ejX                        Z: G dA dBejX                        Z; G dC dDeejX                        Z< G dE dFejX                        Z= G dG dHejX                        Z> G dI dJejX                        Z?y)K    N   )AssertsCompiledSQL)AssertsExecutionResults)config)fixtures)assert_raises)eq_)in_)	CursorSQL)Column)Table   )	bindparam)case)column)Computed)exists)false)
ForeignKey)func)Identity)Integer)literal)literal_column)null)select)String)table)testing)text)true)tuple_)	TupleType)union)values)DatabaseError)ProgrammingErrorc                   n    e Zd ZdZed        Zed        Zd Zej                  j                  d        Z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     MD:\EasyAligner\venv\Lib\site-packages\sqlalchemy/testing/suite/test_select.pydefine_tableszCollateTest.define_tables4   s*    4d366#;'		
    c                 |    |j                  | j                  j                  j                         ddddddg       y )N   collate data1r,   r/   r   collate data2executetablesr+   insertr3   
connections     r5   insert_datazCollateTest.insert_data=   s;    JJ!!((*/2/2	
r7   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       r5   _assert_resultzCollateTest._assert_resultG   <    YY DV$--/8 !     *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)r9   r:   )r   r<   )r   requiresget_order_by_collationr   rN   r   r?   r+   order_bycr/   collateasc)rK   	collations     r5   test_collate_order_byz!CollateTest.test_collate_order_byK   s    $$;;GNNK	4;;))*33&&((--55i@DDF "#78		
r7   N)__name__
__module____qualname____backend__classmethodr6   rC   rN   r   rR   order_by_collationrY    r7   r5   r)   r)   1   sR    K
 
 
 
9 ((
 )
r7   r)   c                       e Zd ZdZdZed        Zed        Zd Zd Z	d Z
d Zd	 Zd
 Zej                  j                   d        Z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   pr1   r2   s     r5   r6   zOrderByLabelTest.define_tablesb   sL    4d33 3 3r
#3r
#	
r7   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 )Nr9   r   q1p3)r,   rd   re   rf   rh   r   q2p2   q3p1r=   rA   s     r5   rC   zOrderByLabelTest.insert_datan   sU    JJ!!((*qqt$?qqt$?qqt$?	
r7   c                     t         j                  j                         5 }t        |j	                  |      j                         |       d d d        y # 1 sw Y   y xY wrE   rF   rJ   s       r5   rN   zOrderByLabelTest._assert_resulty   rO   rP   c                     | j                   j                  }|j                  j                  j	                  d      }| j                  t        |      j                  |      g d       y )Nlxr9   r   r   )r?   r+   rU   rd   labelrN   r   rT   rK   r   rs   s      r5   
test_plainzOrderByLabelTest.test_plain}   sG    &&WWYY__T"F2J//35GHr7   c                     | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }| j                  t        |      j                  |      g d       y )Nrs   )rw         )	r?   r+   rU   rd   re   rx   rN   r   rT   ry   s      r5   test_composed_intz"OrderByLabelTest.test_composed_int   sV    &&ggii%''))#**40F2J//35GHr7   c                    | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }t        j                  |j                  j                        |j                  j                  z   j                  d      }| j                  t        ||      j                  ||j                               g d       y )Nrs   ly))r   q1p3)r}   q2p2)r   q3p1)r?   r+   rU   rd   re   rx   r   lowerrf   rh   rN   r   rT   desc)rK   r   rs   r   s       r5   test_composed_multiplez'OrderByLabelTest.test_composed_multiple   s    &&ggii%''))#**40jj#eggii/66t<2rN##B	23	
r7   c                     | j                   j                  }|j                  j                  j	                  d      }| j                  t        |      j                  |j                               g d       y )Nrs   )rw   rv   ru   )	r?   r+   rU   rd   rx   rN   r   rT   r   ry   s      r5   test_plain_descz OrderByLabelTest.test_plain_desc   sM    &&WWYY__T"F2J//	:<NOr7   c                    | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }| j                  t        |      j                  |j                               g d       y )Nrs   )r~   r|   rw   )
r?   r+   rU   rd   re   rx   rN   r   rT   r   ry   s      r5   test_composed_int_descz'OrderByLabelTest.test_composed_int_desc   s\    &&ggii%''))#**40F2J//	:<NOr7   c                 r   | j                   j                  }|j                  j                  |j                  j                  z   j                  d      }t        t        j                  |j                  j                        |      j                  |      j                  |      }| j                  |g d       y )Nrs   ))r9   r   )r9   r}   )r9   r   )r?   r+   rU   rd   re   rx   r   r   countr,   group_byrT   rN   )rK   r   exprstmts       r5   test_group_by_composedz'OrderByLabelTest.test_group_by_composed   s    &&		EGGII%,,T24::eggjj)4099$?HHN 	 	D":;r7   N)rZ   r[   r\   __doc__r]   r^   r6   rC   rN   rz   r   r   r   r   r   rR   group_by_complex_expressionr   r`   r7   r5   rb   rb   W   sv     K	
 	
 
 
9I
I

P
P
 11< 2<r7   rb   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   ))r9   name1)r   name2)r   name3)	r%   r   r   r   r/   r	   r>   r   all)rK   rB   
value_exprs      r5   test_tuplesz ValuesExpressionTest.test_tuples   sX    4!6&&#9

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

 	JJqM-	
r7   c                 D   | j                   j                  }t        |j                  j                        j                  d      j                         }t        t        |      t        |            j                         j                         }| j                  ||dg       y )Nr9   ru   )
r?   r+   r   rU   r,   r   scalar_subqueryr$   subqueryrN   )rK   rB   r   r   us        r5    test_limit_render_multiple_timesz5FetchLimitOffsetTest.test_limit_render_multiple_times   sy    &&eggjj!''*::<&,t-668??A	
r7   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   r?   r+   rN   r   rT   rU   r,   fetchrK   rB   r   s      r5   test_simple_fetchz&FetchLimitOffsetTest.test_simple_fetch   s    &&5M""577::.44Q7	"	

 	5M""577::.44Q7-	
r7   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   rn   rn   r}   r}   rn   r   r   r   r   r?   r+   rN   r   rT   rU   r,   offsetr   s      r5   test_simple_offsetz'FetchLimitOffsetTest.test_simple_offset  s    &&5M""577::.55a8-	

 	5M""577::.55a8	"	
r7   )r   r   r   r9   r   r   )r   r   r   )r   r9   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   )
r?   r+   execution_optionsrN   r   rT   rU   r,   r   r   )rK   rB   r   r   assert_datar   r   expecteds           r5   test_simple_limit_offsetz-FetchLimitOffsetTest.test_simple_limit_offset  s     &&111D
M"ME6"6FUN;Hu&&uwwzz288?FFvN #r7   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   r9   r   r   r   r   	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_simple_fetch_offsetz-FetchLimitOffsetTest.test_simple_fetch_offset*  s    &&5M""577::.44Q7>>qA	"	
 	5M""577::.44Q7>>qA-	
r7   c                     | j                   j                  }| j                  |t        |      j	                  d      g dd       y )N
   r   Tr   )r?   r+   rN   r   r   r   s      r5   test_fetch_offset_no_orderz/FetchLimitOffsetTest.test_fetch_offset_no_order9  s?    &&5M#C	 	 	
r7   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   r9   r   r   r   r   r   r   s      r5   test_simple_offset_zeroz,FetchLimitOffsetTest.test_simple_offset_zeroC  s    &&5M""577::.55a8C	
 	5M""577::.55a88	
r7   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   r9   literal_bindsT)dialectcompile_kwargsr   r   N)r?   r+   r   rT   rU   r,   r   r   compiler   rG   r   strr   rK   r   r   sqls       r5   test_limit_offset_nobindsz.FetchLimitOffsetTest.test_limit_offset_nobindsR       &&e}%%eggjj177:AA!DllII%%6M  
 #hi%;<r7   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   )r?   r+   r   rT   rU   r,   r   r   r   r   rG   r   r   r   r   s       r5   test_fetch_offset_nobindsz.FetchLimitOffsetTest.test_fetch_offset_nobinds_  r   r7   c                    | j                   j                  }| 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   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_bound_limitz%FetchLimitOffsetTest.test_bound_limitl  s    &&5M""577::.44Ys^D	"8	 	 	
 	5M""577::.44Ys^D-8	 	 	
r7   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   r9   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_bound_offsetz&FetchLimitOffsetTest.test_bound_offset}  s    &&5M""577::.55inE-8	 	 	
 	5M""577::.55inE88	 	 	
r7   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   r9   )r   r   r   r   r   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_bound_limit_offsetz,FetchLimitOffsetTest.test_bound_limit_offset      &&5MXeggjj!U9S>"VIcN#	"# 	 	
 	5MXeggjj!U9S>"VIcN#-# 	 	
r7   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   r9   )r   r   r   r   r   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_bound_fetch_offsetz,FetchLimitOffsetTest.test_bound_fetch_offset  r   r7   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         ddg       y )N12r   r   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_expr_offsetz%FetchLimitOffsetTest.test_expr_offset  s\    &&5MXeggjj!VN3'.*==>	"	
r7   c           	          | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  t        d      t        d      z         g d       y )Nr  r  r   )	r?   r+   rN   r   rT   rU   r,   r   r   r   s      r5   test_expr_limitz$FetchLimitOffsetTest.test_expr_limit  sW    &&5MXeggjj!U>#&)<<=-	
r7   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   
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_expr_limit_offsetz+FetchLimitOffsetTest.test_expr_limit_offset  su    &&5MXeggjj!U>#&)<<=VN3'.*==>	"	
r7   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  )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_expr_fetch_offsetz+FetchLimitOffsetTest.test_expr_fetch_offset  sw     &&5MXeggjj!U>#&)<<=VN3'.*==>	"	
r7   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   )
r?   r+   rN   r   rT   rU   r,   r   r   r   r   s      r5   test_simple_limit_expr_offsetz2FetchLimitOffsetTest.test_simple_limit_expr_offset  s    &&5MXeggjj!U1XVN3'.*==>	"	
 	5MXeggjj!U1XVN3'.*==>-	
r7   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   r9   r   r	  r   s      r5   test_expr_limit_simple_offsetz2FetchLimitOffsetTest.test_expr_limit_simple_offset   s    &&5MXeggjj!U>#&)<<=VAY	"	
 	5MXeggjj!U>#&)<<=VAY	"	
r7   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 )	Nr9   T	with_tiesr   r   r   r   r   	r?   r+   rN   r   rT   rU   rd   r   r   r   s      r5   test_simple_fetch_tiesz+FetchLimitOffsetTest.test_simple_fetch_ties  s    &&5M""57799>>#34::1:M	"	 	 	
 	5M""57799>>#34::1:M-	 	 	
r7   c                 R   | j                   j                  }|j                  t        |      j	                  |j
                  j                        j                  dd      j                  d            j                         }t        |d   d       t        t        |      h d       y )Nr   Tr  r   r      r   r   r   r?   r+   r>   r   rT   rU   rd   r   r   rI   r	   r   rK   rB   r   fas       r5   test_fetch_offset_tiesz+FetchLimitOffsetTest.test_fetch_offset_ties&  s~     &&5MXeggii U1U%VAY	

 (* 	 	BqE9CG67r7   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  r9   r   r   r   r   r   )	r?   r+   rN   r   rT   rU   rd   r   r   r   s      r5   #test_fetch_offset_ties_exact_numberz8FetchLimitOffsetTest.test_fetch_offset_ties_exact_number3  s     &&5MXeggii U1U%VAY	"	
 	5MXeggii U1U%VAY	"	
r7   c                     | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  dd      dg       y )N   Tpercentr   r   r   s      r5   test_simple_fetch_percentz.FetchLimitOffsetTest.test_simple_fetch_percentI  sQ    &&5M""577::.44R4FK	
r7   c                     | j                   j                  }| j                  |t        |      j	                  |j
                  j                        j                  dd      j                  d      ddg       y )N(   Tr   r9   r   r   r   r   s      r5   test_fetch_offset_percentz.FetchLimitOffsetTest.test_fetch_offset_percentR  s\     &&5MXeggjj!U2tU$VAY	"	
r7   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      r5   test_simple_fetch_percent_tiesz3FetchLimitOffsetTest.test_simple_fetch_percent_ties_  sd     &&5MXeggiinn&'U2ttU4	" 	 	
r7   c                 T   | j                   j                  }|j                  t        |      j	                  |j
                  j                        j                  ddd      j                  d            j                         }t        |d   d       t        t        |      h d       y )Nr$  Tr'  r   r   r   r  r  r  s       r5   test_fetch_offset_percent_tiesz3FetchLimitOffsetTest.test_fetch_offset_percent_tiesl  s     &&5MXeggii U2ttU4VAY	

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

/F,>,>>)
%
% 	,335ayA:,,.q10MNr7   c           
      .   | j                  ddt        j                  z        \  }}t        |j	                  t        ||      j                  |||j                  j                  |j                  j                  k(              j                         d       y )Nr+   r?  r9   r9   r9   )r?   r   r=  r	   r>   r   	join_fromrU   r:  r,   firstrK   rB   r+   r@  s       r5   test_simple_join_both_tablesz5SameNamedSchemaTableTest.test_simple_join_both_tables  s    (,/F,>,>>)
%
% 	z#45??%LL..2C2E2E2H2HH eg		
r7   c           
      x   | j                  ddt        j                  z        \  }}t        |j	                  t        |      j                  |||j                  j                  |j                  j                  k(        j                  |j                  j                  dk(              j                         d       y )Nr+   r?  r9   r9   r9   )r?   r   r=  r	   r>   r   rC  rU   r:  r,   whererD  rE  s       r5   !test_simple_join_whereclause_onlyz:SameNamedSchemaTableTest.test_simple_join_whereclause_only  s    (,/F,>,>>)
%
% 	z"%LL..2C2E2E2H2HH
 z||!+, eg	
r7   c           
         | j                  ddt        j                  z        \  }}t        |      j	                  |||j
                  j                  |j
                  j                  k(        j                  |j
                  j                  dk(        j                         }t        |j                  t        ||j
                  j                        j	                  |||j
                  j                  |j
                  j                  k(        j                  |j
                  j                  dk(              j                         d       y )Nr+   r?  r9   rB  )r?   r   r=  r   rC  rU   r:  r,   rI  r   r	   r>   rD  )rK   rB   r+   r@  subqs        r5   test_subqueryz&SameNamedSchemaTableTest.test_subquery  s    (,/F,>,>>)
%
%
 :Y!**.?.A.A.D.DD
 U:<<??a'(XZ 	 	z46699-LL..$&&));
 z||!+, eg	
r7   N)rZ   r[   r\   r   r]   r   r^   r6   rC   rF  rJ  rM  r`   r7   r5   r6  r6  {  sF    KL
 
& O O
 
$
r7   r6  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rE   rF   r   s        r5   rN   zJoinTest._assert_result  >    YY DVV,557@ !  r   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.idFr;  )r   r   r   r   r2   s     r5   r6   zJoinTest.define_tables  sB    c8VD'tDE4d36:f->		
r7   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,   r9   r   r   rn   r}   )r,   rU  )r>   r?   rS  r@   rT  rA   s     r5   rC   zJoinTest.insert_data  s    JJLL!AYq	D!9tQi$C	

 	JJLL!!$!$!$!$		
r7   c                    | j                  dd      \  }}t        ||      j                  |j                  |            j	                  |j
                  j                  |j
                  j                        }| j                  |g d       y NrS  rT  )rB  )r9   r   r9   )r   rn   r   )r   r}   r   r?   r   select_fromjoinrT   rU   r,   rN   rK   rS  rT  r   s       r5   test_inner_join_fkzJoinTest.test_inner_join_fk   b    {{3$1a|''q	2;;ACCFFACCFFKD"NOr7   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 )NrS  rT  )ru   rv   rw   rn   r|   )rH  r   )rn   r   )r}   r   )r?   r   rZ  r[  r!   rT   rU   r,   rN   	itertoolsproduct)rK   rS  rT  r   rU   s        r5   test_inner_join_truezJoinTest.test_inner_join_true  s    {{3$1 1aL[46*+Xaccffaccff% 	 	 %.$5$524%%LDQ&1a Aq	%		
s   +C	c                 (   | j                  dd      \  }}t        ||      j                  |j                  |t	                           j                  |j                  j                  |j                  j                        }| j                  |g        y )NrS  rT  )	r?   r   rZ  r[  r   rT   rU   r,   rN   r\  s       r5   test_inner_join_falsezJoinTest.test_inner_join_false  sk    {{3$1 1aL[57+,Xaccffaccff% 	 	D"%r7   c                 ,   | j                  dd      \  }}t        ||      j                  |j                  |t	                           j                  |j                  j                  |j                  j                        }| j                  |g d       y )NrS  rT  ))r9   NN)r   NN)r   NN)rn   NN)r}   NN)	r?   r   rZ  	outerjoinr   rT   rU   r,   rN   r\  s       r5   test_outer_join_falsezJoinTest.test_outer_join_false&  sq    {{3$1 1aL[Q01Xaccffaccff% 	 			
r7   c                    | j                  dd      \  }}t        ||      j                  |j                  |            j	                  |j
                  j                  |j
                  j                        }| j                  |g d       y rX  rY  r\  s       r5   test_outer_join_fkzJoinTest.test_outer_join_fk:  r^  r7   Nr+  )rZ   r[   r\   r]   rN   r^   r6   rC   r]  rc  re  rh  rj  r`   r7   r5   rO  rO    sP    KA 
 
 
 
 P
(	&
(Pr7   rO  c                   *   e Zd ZdZed        Zed        ZddZd Zd Z	e
j                  j                  e
j                  j                  d               Ze
j                  j                  d        Zd	 Ze
j                  j                  d
        Zd Zy)CompoundSelectTestTc           
      z    t        d|t        dt        d      t        dt              t        dt                     y r   r   r2   s     r5   r6   z CompoundSelectTest.define_tablesE  r   r7   c           
          |j                  | j                  j                  j                         ddddddddddddddddg       y )Nr9   r   r   r   rn   r}   r=   rA   s     r5   rC   zCompoundSelectTest.insert_dataO  sS    JJ!!((*qq)qq)qq)qq)		
r7   c                     t         j                  j                         5 }t        |j	                  ||      j                         |       d d d        y # 1 sw Y   y xY wrE   rF   r   s        r5   rN   z!CompoundSelectTest._assert_result[  rQ  r   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   )
r?   r+   r   rI  rU   r,   r$   rN   rT   selected_columnsrK   r   s1s2u1s        r5   test_plain_unionz#CompoundSelectTest.test_plain_union_  s    &&E]  q1E]  q12r]KK++../)Y1G	
r7   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 rq  )r?   r+   r   rI  rU   r,   r$   aliasrN   rT   rr  rs  s        r5   test_select_from_plain_unionz/CompoundSelectTest.test_select_from_plain_unioni  s    &&E]  q1E]  q12r]  "))+KK++../)Y1G	
r7   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   r9   r   r   r   )r?   r+   r   rI  rU   r,   r   rT   r$   rN   rr  rs  s        r5   &test_limit_offset_selectable_in_unionsz9CompoundSelectTest.test_limit_offset_selectable_in_unionss  s     &&E]  q177:CCEGGJJOE]  q177:CCEGGJJO2r]  #KK++../)Y1G	
r7   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 rq  )r?   r+   r   rI  rU   r,   rT   r$   r   rN   rr  rs  s        r5   "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	
r7   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 rq  )r?   r+   r   rI  rU   r,   distinctr$   r   rN   rT   rr  rs  s        r5   "test_distinct_selectable_in_unionsz5CompoundSelectTest.test_distinct_selectable_in_unions  s    &&E]  q1::<E]  q1::<2r]  #KK++../)Y1G	
r7   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 r|  )r?   r+   r   rI  rU   r,   r   rT   r$   ry  rN   rs  s        r5   &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	
r7   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 r|  )r?   r+   r   rI  rU   r,   r   rT   ry  r$   rN   rr  rs  s        r5   .test_limit_offset_aliased_selectable_in_unionszACompoundSelectTest.test_limit_offset_aliased_selectable_in_unions  s    &&5MU577::?#U1XXeggjj!UWVX 	 5MU577::?#U1XXeggjj!UWVX 	 2r]  #KK++../)Y1G	
r7   Nr+  )rZ   r[   r\   r]   r^   r6   rC   rN   rw  rz  r   rR   order_by_col_from_union/parens_in_union_contained_select_w_limit_offsetr}  0parens_in_union_contained_select_wo_limit_offsetr  r  r  r  r`   r7   r5   rl  rl  B  s    K
 
 	
 	
A

 --EE
 F .
 FF
 G

 EE	
 F	

r7   rl  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-   rd   re   zrg   r1   r2   s     r5   r6   z#PostCompileParamsTest.define_tables  >    4d33 3 3r
#	
r7   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 Nr9   r   z1)r,   rd   re   r  r   z2rn   z3r}   z4r=   rA   s     r5   rC   z!PostCompileParamsTest.insert_data  [    JJ!!((*qqt4qqt4qqt4qqt4		
r7   c                     | j                   j                  }t        |j                  j                        j                  |j                  j                  t        dd      k(        }| j                  |di        y )Nrf   Tliteral_executezKSELECT some_table.id FROM some_table WHERE some_table.x = __[POSTCOMPILE_q]	r?   r+   r   rU   r,   rI  rd   r   assert_compilerK   r   r   s      r5   test_compilez"PostCompileParamsTest.test_compile  s`    &&eggjj!''GGII3==
 	5		
r7   c                     | j                   j                  }t        |j                  j                        j                  |j                  j                  t        ddd      k(        }| j                  |di d       y )Nrf   r   Tr  z<SELECT some_table.id FROM some_table WHERE some_table.x = 10)r   r  r  s      r5   test_compile_literal_bindsz0PostCompileParamsTest.test_compile_literal_binds  sh    &&eggjj!''GGII3DAA
 	J	 	 	
r7   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)Nrf   Tr  r   rf   z>SELECT some_table.id 
FROM some_table 
WHERE some_table.x = 10r`   )r?   r+   r   rU   r,   rI  rd   r   sql_execution_asserterr   rG   rH   r>   dictassert_r   r   
positionalrK   r   r   asserterrM   s        r5   test_executez"PostCompileParamsTest.test_execute  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)Nrf   T	expandingr  )r}   r   r   r  zFSELECT some_table.id 
FROM some_table 
WHERE some_table.x IN (5, 6, 7)r`   )r?   r+   r   rU   r,   rI  rd   r
   r   r  r   rG   rH   r>   r  r  r   r   r  r  s        r5   +test_execute_expanding_plus_literal_executezAPostCompileParamsTest.test_execute_expanding_plus_literal_execute  s    &&eggjj!''GGIIMM)C4NO
 ((*h""$T4)#45 % + 	4ii''22	
 9;	
 %$ +*s$   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)Nrf   Tr  )r}   r   )      r  zbSELECT some_table.id 
FROM some_table 
WHERE (some_table.x, some_table.y) IN (%s(5, 10), (12, 18))VALUES  r`   )r?   r+   r   rU   r,   rI  r"   rd   re   r
   r   r  r   rG   rH   r>   r  r  r   r   tuple_in_valuesr  r  s        r5   1test_execute_tuple_expanding_plus_literal_executezGPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_execute  s   &&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)Nrf   Tr  )r}   r  )r  r  r  zfSELECT some_table.id 
FROM some_table 
WHERE (some_table.x, some_table.z) IN (%s(5, 'z1'), (12, 'z3'))r  r  r`   )r?   r+   r   rU   r,   rI  r"   rd   r  r
   r   r  r   rG   rH   r>   r  r  r   r   r  r  r  s        r5   ?test_execute_tuple_expanding_plus_literal_heterogeneous_executezUPostCompileParamsTest.test_execute_tuple_expanding_plus_literal_heterogeneous_execute1  s   &&eggjj!''57799eggii(,,#tD
 ((*h""$T49j*A#BC % + 	/ !'		 1 1 A A9rK ii''22	
 9;	
 %$ +*r  N)rZ   r[   r\   r]   r   r^   r6   rC   r  r  r  r  r   rR   tuple_inr  r  r`   r7   r5   r  r    s     K+L
 
 	
 	



&
& 
 
. 
 
r7   r  c                      e Zd ZdZed        Zed        Zd#dZd Zd Z	e
j                  j                  d        Ze
j                  j                  d        Ze
j                  j                  d	        Ze
j                  j                  d
        Zd Zd Zd Zd Zd Zd Ze
j                  j.                  d        Ze
j                  j.                  d        Ze
j                  j.                  d        Ze
j                  j.                  d        Ze
j                  j.                  d        Ze
j                  j.                  d        Ze
j                  j.                  d        Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d  Z'd! Z(y")$ExpandingBoundInTestTc                     t        d|t        dt        d      t        dt              t        dt              t        dt        d                   y r  r1   r2   s     r5   r6   z"ExpandingBoundInTest.define_tablesM  r  r7   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=   rA   s     r5   rC   z ExpandingBoundInTest.insert_dataX  r  r7   c                     t         j                  j                         5 }t        |j	                  ||      j                         |       d d d        y # 1 sw Y   y xY wrE   rF   r   s        r5   rN   z#ExpandingBoundInTest._assert_resultd  rQ  r   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 )Nrf   rh   )rf   rh   r   )r?   r+   r   rU   r,   rI  rd   r
   r   re   rT   rN   r  s      r5   "test_multiple_empty_sets_bindparamz7ExpandingBoundInTest.test_multiple_empty_sets_bindparamh  s     &&577::U57799==301U57799==301Xeggjj!	 	 	D"2B-?@r7   c                    | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rE   )r?   r+   r   rU   r,   rI  rd   r
   re   rT   rN   r  s      r5   test_multiple_empty_sets_directz4ExpandingBoundInTest.test_multiple_empty_sets_directt  s     &&577::U57799==$%U57799==$%Xeggjj!	 	 	D"%r7   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  t        d                  j                  |j                  j                        }| j                  |g dg i       y Nrf   r   r?   r+   r   rU   r,   rI  r"   rd   r  r
   r   rT   rN   r  s      r5   )test_empty_heterogeneous_tuples_bindparamz>ExpandingBoundInTest.test_empty_heterogeneous_tuples_bindparam      &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	D"c2Y7r7   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 rE   )
r   rU   r,   rI  r"   rd   r  r
   rT   rN   valr   r   rK   r   s      r5   gozGExpandingBoundInTest.test_empty_heterogeneous_tuples_direct.<locals>.go  h    uwwzz"veggii377<=%''**% 
 h/r7   )r   r  )r   r  )rn   r  rv   rw   r`  r?   r+   rK   r  r   s   ` @r5   &test_empty_heterogeneous_tuples_directz;ExpandingBoundInTest.test_empty_heterogeneous_tuples_direct  s7    &&	0 	2r

,.@A
2r
r7   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  r?   r+   r   rU   r,   rI  r"   rd   re   r
   r   rT   rN   r  s      r5   'test_empty_homogeneous_tuples_bindparamz<ExpandingBoundInTest.test_empty_homogeneous_tuples_bindparam  r  r7   c                 ~      j                   j                   fd} |g g         |g dg d        |g g        y )Nc                 N   t        j                  j                        j                  t	        j                  j
                  j                  j                        j                  |             j                  j                  j                        }j                  ||       y rE   )
r   rU   r,   rI  r"   rd   re   r
   rT   rN   r  s      r5   r  zEExpandingBoundInTest.test_empty_homogeneous_tuples_direct.<locals>.go  r  r7   ))r9   r   r   r   r   rn   rt   r  r  s   ` @r5   $test_empty_homogeneous_tuples_directz9ExpandingBoundInTest.test_empty_homogeneous_tuples_direct  s7    &&	0 	2r

#%78
2r
r7   c                 ^   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg di       y )Nrf   r  r   r   rn   r   r?   r+   r   rU   r,   rI  rd   r
   r   rT   rN   r  s      r5   test_bound_in_scalar_bindparamz3ExpandingBoundInTest.test_bound_in_scalar_bindparam  st    &&577::U57799==301Xeggjj! 	
 	D"4c9=MNr7   c                 D   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  
r?   r+   r   rU   r,   rI  rd   r
   rT   rN   r  s      r5   test_bound_in_scalar_directz0ExpandingBoundInTest.test_bound_in_scalar_direct  sf    &&577::U57799==+,Xeggjj! 	
 	D"45r7   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   rv   rw   r?   r+   r   rU   r,   rI  rd   r
   not_inrT   rN   r  s      r5   !test_nonempty_in_plus_empty_notinz6ExpandingBoundInTest.test_nonempty_in_plus_empty_notin  s    &&577::U57799==!Q()U577::$$R()Xeggjj!	 	 	D4,/r7   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      r5   !test_empty_in_plus_notempty_notinz6ExpandingBoundInTest.test_empty_in_plus_notempty_notin  s    &&577::U57799==$%U577::$$aV,-Xeggjj!	 	 	D"%r7   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 idrf   Ttype_r  r  r  r  r  r   N)r    
bindparamsr   r   rN   rK   r   s     r5   test_typed_str_inz&ExpandingBoundInTest.test_typed_str_in  sK     A

*Ys&DA
B 	 	+, 	 	
r7   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  rf   Tr  r  r  r   Nr    r  r   rN   r  s     r5   test_untyped_str_inz(ExpandingBoundInTest.test_untyped_str_in  sI     A

*Ysd3
4 	 	+, 	 	
r7   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 )Nrf   r  r  r  )rn   r}   r   r  r  s      r5   !test_bound_in_two_tuple_bindparamz6ExpandingBoundInTest.test_bound_in_two_tuple_bindparam  s    &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	$c3K-L 	 	
r7   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  )r?   r+   r   rU   r,   rI  r"   rd   re   r
   rT   rN   r  s      r5   test_bound_in_two_tuple_directz3ExpandingBoundInTest.test_bound_in_two_tuple_direct	  sx    &&577::U6%''))UWWYY/334LMNXeggjj! 	
 	D"45r7   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 )Nrf   r  r  r   r  r  s      r5   /test_bound_in_heterogeneous_two_tuple_bindparamzDExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_bindparam  s    &&577::U6%''))UWWYY/33IcNCDXeggjj! 	
 	:; 	 	
r7   c                    | j                   j                  }t        |j                  j                        j                  t        |j                  j                  |j                  j                        j                  g d            j                  |j                  j                        }| j                  |g d       y )Nr  r  )r?   r+   r   rU   r,   rI  r"   rd   r  r
   rT   rN   r  s      r5   ,test_bound_in_heterogeneous_two_tuple_directzAExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_direct!  s    &&577::Uuwwyy%'')),005
 Xeggjj! 	 		
r7   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 idrf   Tr  r  r  r   r  r  s     r5   4test_bound_in_heterogeneous_two_tuple_text_bindparamzIExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam2  sI     F

*Ysd3
4 	 	:; 	 	
r7   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 rE   _datarK   r/   s     r5   __init__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__init__B  	    !
r7   c                 ,    t        | j                        S rE   iterr  rK   s    r5   __iter__zqExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__iter__E      DJJ''r7   c                      | j                   |   S rE   r  rK   idxs     r5   __getitem__ztExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__getitem__H      zz#&r7   c                 ,    t        | j                        S rE   r   r  r  s    r5   __len__zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple.<locals>.LikeATuple.__len__K      4::&r7   NrZ   r[   r\   r  r  r  r  r`   r7   r5   
LikeATupler  A      "(''r7   r  r  rf   Tr  r  r   r  r   r  rn   r  r   )	collections_abcSequencer    r  r   r#   r   r   rN   rK   r  r   s      r5   ?test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuplezTExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_typed_bindparam_non_tuple?  s    	'11 	' F

*9WY9T
 	 	q$'q$'q$' 	 
	
r7   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 rE   r  r  s     r5   r  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__init__g  r  r7   c                 ,    t        | j                        S rE   r	  r  s    r5   r  zpExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__iter__j  r  r7   c                      | j                   |   S rE   r  r  s     r5   r  zsExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__getitem__m  r  r7   c                 ,    t        | j                        S rE   r  r  s    r5   r  zoExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuple.<locals>.LikeATuple.__len__p  r  r7   Nr  r`   r7   r5   r  r   f  r  r7   r  r  rf   Tr  r  r   r  r   r  rn   r  r   )r  r  r    r  r   rN   r  s      r5   >test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuplezSExpandingBoundInTest.test_bound_in_heterogeneous_two_tuple_text_bindparam_non_tuplea  s}    
	'11 	' F

*Ysd3
4 	 	q$'q$'q$' 	 
	
r7   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      r5   (test_empty_set_against_integer_bindparamz=ExpandingBoundInTest.test_empty_set_against_integer_bindparam  r    &&577::U57799==301Xeggjj! 	
 	D"c2Y7r7   c                 <   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rE   r  r  s      r5   %test_empty_set_against_integer_directz:ExpandingBoundInTest.test_empty_set_against_integer_direct  b    &&eggjj!''		b(9:CCEGGJJOD"%r7   c                 Z   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg i       y Nrf   ru   rv   rw   r`  r   )r?   r+   r   rU   r,   rI  rd   r  r   rT   rN   r  s      r5   1test_empty_set_against_integer_negation_bindparamzFExpandingBoundInTest.test_empty_set_against_integer_negation_bindparam  u    &&577::U57799##IcN34Xeggjj! 	
 	D":C9Mr7   c                 @   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g d       y Nr.  )
r?   r+   r   rU   r,   rI  rd   r  rT   rN   r  s      r5   .test_empty_set_against_integer_negation_directzCExpandingBoundInTest.test_empty_set_against_integer_negation_direct  j    &&577::$$UWWYY%5%5b%9:CCEGGJJO 	 	D":;r7   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+   r   rU   r,   rI  r  r
   r   rT   rN   r  s      r5   'test_empty_set_against_string_bindparamz<ExpandingBoundInTest.test_empty_set_against_string_bindparam  r(  r7   c                 <   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g        y rE   )
r?   r+   r   rU   r,   rI  r  r
   rT   rN   r  s      r5   $test_empty_set_against_string_directz9ExpandingBoundInTest.test_empty_set_against_string_direct  r+  r7   c                 Z   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  t        d                  j                  |j                  j                        }| j                  |g ddg i       y r-  )r?   r+   r   rU   r,   rI  r  r  r   rT   rN   r  s      r5   0test_empty_set_against_string_negation_bindparamzEExpandingBoundInTest.test_empty_set_against_string_negation_bindparam  r0  r7   c                 @   | j                   j                  }t        |j                  j                        j                  |j                  j                  j                  g             j                  |j                  j                        }| j                  |g d       y r2  )
r?   r+   r   rU   r,   rI  r  r  rT   rN   r  s      r5   -test_empty_set_against_string_negation_directzBExpandingBoundInTest.test_empty_set_against_string_negation_direct  r4  r7   c           
          t        t        t               j                  t	        dd            t               ft                           }t        |j                  |      j                         d   d       y )Nfoor`   )valueelse_r   Fr   )	r   r   r   r
   r   r!   r   r>   fetchonerK   rB   r   s      r5   )test_null_in_empty_set_is_false_bindparamz>ExpandingBoundInTest.test_null_in_empty_set_is_false_bindparam  s_    FJJyb9:F g
 	Jt$--/2J?r7   c                     t        t        t               j                  g       t	               ft                           }t        |j                  |      j                         d   d       y )Nr@  r   rB  )r   r   r   r
   r!   r   r>   rC  rD  s      r5   &test_null_in_empty_set_is_false_directz;ExpandingBoundInTest.test_null_in_empty_set_is_false_direct  sW    FJJrNF g
 	Jt$--/2J?r7   Nr+  ))rZ   r[   r\   r]   r^   r6   rC   rN   r  r  r   rR   tuple_in_w_emptyr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r'  r*  r/  r3  r6  r8  r:  r<  rE  rG  r`   r7   r5   r  r  J  s   K
 
 	
 	
A
A
& &&8 '8 && ' &&8 '8 && 'O60&
"
$ 	
 	
 6 6 
 
 
 
  

 

 
 
B 
 
@8&
N<8&
N<
@
@r7   r  c                      e Zd ZdZdZdZed        Zed        Zd Z	d Z
ej                  j                  d        Zd	 Zej                  j                  d
        Zej                  j                  d        Zd Zd Zej                  j                  d        Zej                  j                  d        Zej                  j                  d        Zd Zej                  j                  d        Zej                  j                  d        Zej                  j                  d        Zej                  j6                  d        Zej                  j:                  d        Zej                  j6                   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-   r/   rg   r1   r2   s     r5   r6   zLikeFunctionsTest.define_tables  s*    4d366":&		
r7   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 )Nr9   abcdefgr;   r   zab/cdefgr   zab%cdefgrn   ab_cdefgr}   zabcde/fgr   zabcde%fgr   zab#cdefg   ab9cdefg	   zabcde#fgr   abcd9fg   r=   rA   s     r5   rC   zLikeFunctionsTest.insert_data  s    JJ!!((*),*-*-*-*-*-*-*-*-9-4(	
r7   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rE   )r?   r+   r   rG   rH   r>   r   rU   r,   rI  r	   )rK   r   r   r+   rM   r?  rowss          r5   _testzLikeFunctionsTest._test  s    [[++
YY D #ll6*,,//+B+H+H+NOOFE O   ! 	D( ! s   A B5B BBB%c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Nab%c
   r9   r   r   rn   r}   r   r   rP  rR  r   r?   r+   rU   r/   rW  
startswithrK   cols     r5   test_startswith_unescapedz+LikeFunctionsTest.test_startswith_unescaped  s5    kk$$&&++

3>>&)+JKr7   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )NrY  T
autoescaper   r[  r]  s     r5   test_startswith_autoescapez,LikeFunctionsTest.test_startswith_autoescape  s:    kk$$&&++

3>>&T>:QC@r7   c                     | j                   j                  j                  j                  }| j	                  |j                  t        d            h d       y )Nz'ab%c'rZ  )r?   r+   rU   r/   rW  r\  r   r]  s     r5   test_startswith_sqlexprz)LikeFunctionsTest.test_startswith_sqlexpr  s=    kk$$&&++

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

3>>'#>6<r7   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )NrY  Trg  rb  ri  r   zab#cr   r[  r]  s     r5   !test_startswith_autoescape_escapez3LikeFunctionsTest.test_startswith_autoescape_escape  s[    kk$$&&++

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

3>>&T#>FLr7   c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Ne%fg	   r9   r   r   rn   r}   r   r   rP  rR  r?   r+   rU   r/   rW  endswithr]  s     r5   test_endswith_unescapedz)LikeFunctionsTest.test_endswith_unescaped  s5    kk$$&&++

3<<')DEr7   c                     | j                   j                  j                  j                  }| j	                  |j                  t        d            h d       y )Nz'e%fg'rp  )r?   r+   rU   r/   rW  rr  r   r]  s     r5   test_endswith_sqlexprz'LikeFunctionsTest.test_endswith_sqlexpr#  s=    kk$$&&++

LL124O	
r7   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nro  Tra  r   rq  r]  s     r5   test_endswith_autoescapez*LikeFunctionsTest.test_endswith_autoescape)  s:    kk$$&&++

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

3<<<4qc:r7   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )Nro  Trg  rl  r   ze#fgrR  rq  r]  s     r5   test_endswith_autoescape_escapez1LikeFunctionsTest.test_endswith_autoescape_escape3  [    kk$$&&++

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

3<<4<DqcJr7   c                     | j                   j                  j                  j                  }| j	                  |j                  d      h d       y )Nb%cderp  r?   r+   rU   r/   rW  containsr]  s     r5   test_contains_unescapedz)LikeFunctionsTest.test_contains_unescaped9  s5    kk$$&&++

3<<(*EFr7   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nr~  Tra  r   r  r]  s     r5   test_contains_autoescapez*LikeFunctionsTest.test_contains_autoescape=  s:    kk$$&&++

3<<D<9A3?r7   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      dh       y )Nzb##cderg  rh  r   r  r]  s     r5   test_contains_escapez&LikeFunctionsTest.test_contains_escapeB  s:    kk$$&&++

3<<<5s;r7   c                     | j                   j                  j                  j                  }| j	                  |j                  ddd      dh       | j	                  |j                  ddd      dh       y )Nzb%cdTrg  rl  r   zb#cdr   r  r]  s     r5   test_contains_autoescape_escapez1LikeFunctionsTest.test_contains_autoescape_escapeG  r|  r7   c                     | j                   j                  j                  j                  }| j	                  |j                  d       h d       y )Na.cde>   r   r   rn   r   rP  r   r?   r+   rU   r/   rW  regexp_matchr]  s     r5   test_not_regexp_matchz'LikeFunctionsTest.test_not_regexp_matchM  s:    kk$$&&++

C$$W--/BCr7   c                     | j                   j                  j                  j                  }| j	                  |j                  dd      j                  d      h d       y )Nr  FOO   r9   r}   r   rR  )r?   r+   rU   r/   rW  regexp_replacer  r]  s     r5   test_regexp_replacez%LikeFunctionsTest.test_regexp_replaceR  sF    kk$$&&++

w.77>	
r7   r  r  abc>   r9   r}   r   rR  r   z^abc9cderP  z^ar9   rT  z(b|c)z^(b|c)c                     | j                   j                  j                  j                  }| j	                  |j                  |      |       y rE   r  )rK   r    r   r^  s       r5   test_regexp_matchz#LikeFunctionsTest.test_regexp_matchY  s8     kk$$&&++

3##D)84r7   )#rZ   r[   r\   r]   run_insertsrun_deletesr^   r6   rC   rW  r_  r   rR   like_escapesrc  re  rj  rm  rs  ru  rw  ry  r{  r  r  r  r  r  r  r  r  r-  r   ranger  r`   r7   r5   rJ  rJ    sL   KKK
 
 
 
$	L ""A #A
 ""= #= ""M #M
F
 ""? #? ""; #; ""K #K
G ""@ #@ ""< #< ""K #K
 ""D #D $$
 %
 ""W	,	 !	!"	!	s5B< !	#eArl#$	355 #5r7   rJ  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   r2   s     r5   r6   z ComputedColumnTest.define_tablesl  sH    4d367#67H]$;<;*)=>	
r7   c                 |    |j                  | j                  j                  j                         ddddddg       y )Nr9   r   )r,   r  *   )r>   r?   r  r@   rA   s     r5   rC   zComputedColumnTest.insert_dataw  s8    JJ$$&r"2r$:;	
r7   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*)r9   r   r0   r$  )r   r       )r   rG   rH   r>   r   r    rZ  r?   r  rT   rU   r,   rI   r	   rK   rM   ress      r5   test_select_allz"ComputedColumnTest.test_select_all~  s    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)r0   r$  )r  r  )r   rG   rH   r>   r   r?   r  rU   r  r  rZ  rT   r,   rI   r	   r  s      r5   test_select_columnsz&ComputedColumnTest.test_select_columns  s    YY D,,KK&&((--t{{/A/A/C/C/M/M T[[//0$++,,..112 hj  i-. !  s   C"D

DN)
rZ   r[   r\   r]   r   r^   r6   rC   r  r  r`   r7   r5   r  r  h  s<    K(L
 
 
 
>	/r7   r  c                       e Zd ZdZdZdZdZed        Zed        Z	d Z
d Zej                  j                  d        Zy	)
IdentityColumnTestT)identity_columnsrK  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   r0   tbl_br   i)	incrementr  minvaluemaxvaluer   r   r   r   r   r2   s     r5   r6   z IdentityColumnTest.define_tables  s    rdt ! 66#;'	
 	2QK 	 66#;'
	
r7   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   rS  rT  r  rU   r,   r   )r>   r?   r  r@   r  rA   s     r5   rC   zIdentityColumnTest.insert_data  s    JJ##%c]VSM*	
 	JJ##%c]VSM*	
 	JJ##%$%	
r7   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  rS  )+   rT  ))r  rT  )r   rS  )r  rU   )r>   r   r    rZ  r?   r  rT   rU   r,   rI   r	   r  rK   rB   r  s      r5   r  z"IdentityColumnTest.test_select_all  s      49[**+Xdkk'')),,-
 (*	 	
 	C)Y'(  49[**+Xdkk'')),,-
 (*	 	
 	C12r7   c                 .   |j                  t        | j                  j                  j                  j
                        j                  | j                  j                  j                  j
                              j                         }t        |ddg       y )N)r  )r  )	r>   r   r?   r  rU   r,   rT   rI   r	   r  s      r5   r  z&IdentityColumnTest.test_select_columns  sk      4;;$$&&))*33DKK4E4E4G4G4J4JK

(* 	 	C% r7   c                 @      fd}t        t        t        f|       y )Nc                  v     j                  j                  j                  j                         dddg       y )N   rS  r  )r>   r?   r  r@   )rB   rK   s   r5   fnz7IdentityColumnTest.test_insert_always_error.<locals>.fn  s2    !!((*S)*r7   )r   r&   r'   )rK   rB   r  s   `` r5   test_insert_always_errorz+IdentityColumnTest.test_insert_always_error  s    	 	}&67<r7   N)rZ   r[   r\   r]   r   r  r  r^   r6   rC   r  r  r   rR   identity_columns_standardr  r`   r7   r5   r  r    sf    K(LKK
 
4 
 
3! //= 0=r7   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)r.   autoincrementr   r0   r  r2   s     r5   r6   z'IdentityAutoincrementTest.define_tables  s9    
 " 66#;'	
r7   c                 
   |j                  | j                  j                  j                         ddi      }|j                  | j                  j                  j	                               j                         }t        |d       y )Nr   row)r9   r  )r>   r?   r  r@   r   rD  r	   r  s      r5    test_autoincrement_with_identityz:IdentityAutoincrementTest.test_autoincrement_with_identity  s]      !7!7!9FE?K  !7!7!9:@@BCr7   N)rZ   r[   r\   r]   r   r^   r6   r  r`   r7   r5   r  r    s#    K6L
 
r7   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-   r/   rg   r1   r2   s     r5   r6   zExistsTest.define_tables  s*    4d366":&		
r7   c           	          |j                  | j                  j                  j                         ddddddddddddg       y )Nr9   	some datar;   r   r   rn   zsome other data)r>   r?   r  r@   rA   s     r5   rC   zExistsTest.insert_data  sL    JJ##%+.+.+."34		
r7   c           
      "   | j                   j                  }t        |j                  t	        t        d            j                  t               j                  |j                  j                  dk(                    j                         dg       y )Nr9   r  ru   r?   r  r	   r>   r   r   rI  r   rU   r/   rI   rK   rB   r  s      r5   test_select_existszExistsTest.test_select_exists  sg    !!wqz"((HNN577<<;#>? hjF	
r7   c           
          | j                   j                  }t        |j                  t	        t        d            j                  t               j                  |j                  j                  dk(                    j                         g        y )Nr9   zno datar  r  s      r5   test_select_exists_falsez#ExistsTest.test_select_exists_false  se    !!wqz"((HNN577<<9#<= hj	
r7   N)	rZ   r[   r\   r]   r^   r6   rC   r  r  r`   r7   r5   r  r    s7    K
 
 	
 	
	
	
r7   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  rf   r>  z:DISTINCT ON is currently supported only by the PostgreSQL zSELECT DISTINCT * FROM foo)r   r  r   rZ  r   r   expect_deprecatedr  )rK   stms     r5   test_distinct_onzDistinctOnTest.test_distinct_on.  s]    Sk""6#;/;;E%LI&&H
 %AB
 
 
s   A--A6N)	rZ   r[   r\   r]   r   fails_ifrR   supports_distinct_onr  r`   r7   r5   r  r  +  s4    KWg&&;;<C =Cr7   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   r2   s     r5   r6   z'IsOrIsNotDistinctFromTest.define_tables;  s4    4d37Gd37Gd3	
r7   )both_int_differentr   r9   r9   )both_int_samer9   r9   r   )one_null_firstNr9   r9   )one_null_secondr   Nr9   )	both_nullNNr   iaaaz3col_a_value, col_b_value, expected_row_count_for_is)id_r   c                    | j                   j                  }|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 )Nr9   )r,   r  r  r   )r?   r  r>   r@   r   rI  rU   r  is_distinct_fromr  rI   r	   r   is_not_distinct_from)rK   col_a_valuecol_b_valueexpected_row_count_for_isrB   r  rL   expected_row_count_for_is_nots           r5   test_is_or_is_not_distinct_fromz9IsOrIsNotDistinctFromTest.test_is_or_is_not_distinct_fromE  s    kk**JJLkBC	

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

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

(* 	 	K)	
r7   N)
rZ   r[   r\   r]   r   r^   r6   r   r-  r  r`   r7   r5   r  r  7  sT    K1L
 
 W'"&'$F

r7   r  c                   @    e Zd ZdZdZed        Zed        Zd Zd Z	y)WindowFunctionTest)window_functionsTc           
      z    t        d|t        dt        d      t        dt              t        dt                     y )Nr+   r,   Tr-   col1col2r   r2   s     r5   r6   z WindowFunctionTest.define_tablesq  s0    4d367#67#	
r7   c           
          |j                  | j                  j                  j                         t	        dd      D cg c]  }|||dz  d c}       y c c}w )Nr9   rg   r}   )r,   r  r   )r>   r?   r+   r@   r  )r3   rB   is      r5   rC   zWindowFunctionTest.insert_data{  sL    JJ!!((*:?2,G,QAq!a%0,G	
Gs   A
c                    | j                   j                  }|j                  t        t	        j
                  |j                  j                        j                  |j                  j                  j                         g            j                  |j                  j                  dk              j                         }t        |t        d      D cg c]  }d c}       y c c}w )N)rT   r     )_   )r?   r+   r>   r   r   maxrU   r   overr  r   rI  r   r	   r  rK   rB   r+   rV  r  s        r5   test_windowzWindowFunctionTest.test_window  s    [[++
!!**+00(ll//4467 1  eJLL%%*+
 #% 	 	D%),)Q5),-,s   	C#
c                 p   | j                   j                  }|j                  t        t	        j
                  |j                  j                        j                  |j                  j                  gd                  j                         }t        |t        ddd      D cg c]  }|f c}       y c c}w )N)r  r   )rT   rV  r}      )r?   r+   r>   r   r   r  rU   r   r  r  r   r	   r  r  s        r5   test_window_rows_betweenz+WindowFunctionTest.test_window_rows_between  s    [[++
 !!**+00(ll//0  1 
 #% 	 	Dq#q!12!1AA4!1232s   !
B3
N)
rZ   r[   r\   r   r]   r^   r6   rC   r	  r  r`   r7   r5   r  r  l  s<    (LK
 
 
 

.4r7   r  c                      e Zd ZdZdxZZ ed      D  cg c]
  }||dz   d c}} Zed        Z	ed        Z
 ej                  d  ed      D  cg c]
  }|d	k7  s	| c}} ej                  j                  fd
  e ed            ej                  j                   fd  e edd            ej                  j"                  fd dgej                  j$                  fd  e edd            ej                  j&                  fd  e edd            ej                  j&                  fd      d        Zyc c}} w c c}} w )BitwiseTestTrK  r   r9   )rS  rT  c           	      X    t        d|t        dt              t        dt                     y )NbitwiserS  rT  r   r2   s     r5   r6   zBitwiseTest.define_tables  s    i6#w#7W9MNr7   c                     |j                  | j                  j                  j                         | j                         y rE   )r>   r?   r  r@   inserted_datarA   s     r5   rC   zBitwiseTest.insert_data  s+    3::--4468I8IJr7   c                 $    | j                  d      S )Nr}   )bitwise_xorrS  s    r5   <lambda>zBitwiseTest.<lambda>      ammA&r7   r}   c                 $    | j                  d      S Nr9   )
bitwise_orr  s    r5   r  zBitwiseTest.<lambda>  s    all1or7   c                 $    | j                  d      S )Nrn   )bitwise_andr  s    r5   r  zBitwiseTest.<lambda>  r  r7   rn   rP  c                 (    | dz
  j                         S Nr   )bitwise_notr  s    r5   r  zBitwiseTest.<lambda>  s    q1u))+r7   r   c                 $    | j                  d      S r  )bitwise_lshiftr  s    r5   r  zBitwiseTest.<lambda>      a&&q)r7   c                 $    | j                  d      S r  )bitwise_rshiftr  s    r5   r  zBitwiseTest.<lambda>  r"  r7   zcase, expectedr   c                    | j                   j                  }|j                  j                  }t	        j
                  ||      }t        |      j                  |dkD        j                  |      }|j                  |      j                         j                         }t        ||D 	cg c]  }	| j                  |	    c}	       y c c}	w )Nr  r   )r?   r  rU   rS  r   resolve_lambdar   rI  rT   r>   mappingsr   r	   r  )
rK   r   r   rB   r  rS  opr   r  r  s
             r5   test_bitwisezBitwiseTest.test_bitwise  s    D kk!!EEGG##DA.c{  a(11!4  &//1557C:A$$$Q':;:s   'C
N)rZ   r[   r\   r]   r  r  r  r  r^   r6   rC   r   r-  rR   supports_bitwise_xorlistsupports_bitwise_orsupports_bitwise_andsupports_bitwise_notsupports_bitwise_shiftr)  ).0r  s   00r5   r  r    sz   K &&K+389=9a11q5)9=MO O K K W&b	,	1Q!VQ	,11	
 &rO00	
 'q!11	
 ,C11	
 *q"33	
 *q"33	

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