
    [h                       d dl Z d dlZd dl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/ dd'lm0Z0 dd(lm1Z1 dd)lm2Z2 dd*lm3Z3 d+\  Z4Z5 G d, d-ej6                  Z7 G d. d/e7          Z8 G d0 d1ej6                  Z9 G d2 d3ej:                  Z; G d4 d5ej6                  Z<d6 Z= G d7 d8e0e7          Z> G d9 d:ej:                  Z? G d; d<e/ej:                  Z@ G d= d>ej6                  ZA G d? d@ejB                  ZC G dA dBej6                  ZD G dC dDej6                  ZEdEZFdS )F    N   )config)engines)eq_)eq_regex)expect_raises)expect_raises_message)expect_warnings)fixtures)is_)get_temp_table_name)temp_table_keyword_argsColumn)Table   )Boolean)DateTime)event)
ForeignKey)func)Identity)inspect)Integer)MetaData)String)testing)types)	Inspector)
ObjectKind)ObjectScope)NoSuchTableError)UnreflectableTableError)DDL)Index)quoted_name)BLANK_SCHEMA)ComparesIndexes)ComparesTables)is_false)is_true)mockNNc                   $    e Zd Zed             ZdS )OneConnectionTablesTestc                     t           j        j        j        r/ddlm} t          j        t          |j	        d                    S t           j
        S )Nr   )poolclass)	poolclassscope)options)r   requirementsindependent_connectionsenabled
sqlalchemyr1   r   testing_enginedict
StaticPooldb)clsr1   s     w/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/testing/suite/test_reflection.py
setup_bindz"OneConnectionTablesTest.setup_bind;   s]    
 6> 	'''''')tgFFF    9    N)__name__
__module____qualname__classmethodr@    rA   r?   r/   r/   :   s-          [  rA   r/   c                      e Zd ZdZed             Zed             Zed             Ze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        ej        j        ej        j        d                                     Zej        j        ej        j        d                         ZdS )HasTableTestTc                    t          d|t          dt          d          t          dt          d                               t          j        j        j        rNt          d|t          dt          d          t          dt          d                    t          j	                   t          j        j
        r|                     |           t          j        j        j        r|                     |           d S d S )	N
test_tableidTprimary_keydata2   test_table_sschema)r   r   r   r   r   requiresschemasr8   r   test_schemaview_reflectiondefine_viewshas_temp_tabledefine_temp_tablesr>   metadatas     r?   define_tableszHasTableTest.define_tablesM   s    4d33366"::&&		
 	
 	
 #+ 	tW$777vvbzz**)    + 	'X&&&*2 	-""8,,,,,	- 	-rA   c                    d}t          j        |dt          |                     t          j        |dt          d                     t          j        j        j        rrdt          j        dt          j        d}t          j        |dt          |                     t          j        |dt          dt          j        z                       d S d S )	Nz1CREATE VIEW vv AS SELECT id, data FROM test_tableafter_createbefore_dropzDROP VIEW vvCREATE VIEW z.vv AS SELECT id, data FROM z.test_table_szDROP VIEW %s.vv)	r   listenr$   r   rS   rT   r8   r   rU   )r>   r[   querys      r?   rW   zHasTableTest.define_viewsc   s    CX~s5zz:::X}c..A.ABBB#+ 	 	 &&&&&&  L>3u::>>>L%);<==    	 	rA   c                 \    t          t          t          j        dt          j                   S N	user_tmp_r   r   r=   identr>   s    r?   temp_table_namezHasTableTest.temp_table_namey   (    "FI96<99
 
 	
rA   c                    t          t          t          j                  }|                                 }t	          ||t          dt          j        d          t          dt          j        d                    fi |}t          j
        j        j        rkt          j
        j        j        rWt          j        |dt!          dt          j        z                       t          j        |dt!          d	                     d S d S d S )
NrK   TrL   namerO   r^   =create temporary view user_tmp_v as select * from user_tmp_%sr_   drop view user_tmp_v)r   r   r=   ri   r   r   saINTVARCHARr   rS   rV   r8   temporary_viewsr   ra   r$   rg   r>   r[   kw
table_nameuser_tmps        r?   rY   zHasTableTest.define_temp_tables   s   $VVY77((**
4T22262:b>>**	
 

 
 
 ,4	O 08	O L028,?    L=#6L2M2MNNNNN	O 	O 	O 	OrA   c                    t           j                                        5 }t          t           j        j                            |d                     t          t           j        j                            |d                     t          t           j        j                            |d                     d d d            d S # 1 swxY w Y   d S )NrJ   rP   nonexistent_table)r   r=   beginr+   dialect	has_tabler*   selfconns     r?   test_has_tablezHasTableTest.test_has_table   s    Y__ 	M$FI%//lCCDDDVY&00~FFGGGVY&007JKKLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	Ms   BCC
Cc                 ~   t          t          j                  }t          |                    d                     t          d|t          dt                              }t          |                    d                     |	                    t          j                   	 t          |                    d                     |
                                 t          |                    d                     |                    t          j                   d S # |                    t          j                   w xY w)NrJ   	new_tablecol)r   r   r=   r+   r{   r   r   r   r*   createclear_cachedrop)r}   r[   inspnts       r?   test_has_table_cachez!HasTableTest.test_has_table_cache   s    vy!!|,,---;&*@*@AA,,---
		&)	T^^K00111DNN;//000GGFIBGGFIs   "AD !D<c                    t           j                                        5 }t          t           j        j                            |dt           j                             t          t           j        j                            |dt           j                             t          t           j        j                            |dt           j                             d d d            d S # 1 swxY w Y   d S )NrJ   rQ   rP   rx   )r   r=   ry   r*   rz   r{   rU   r+   r|   s     r?   test_has_table_schemaz"HasTableTest.test_has_table_schema   s%   Y__ 	$	!++,v/A ,    
 	!++.1C ,    
 	!++-f6H ,    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B;C''C+.C+c                     t           j                                        5 }t          t           j        j                            |dd                     d d d            d S # 1 swxY w Y   d S )NrJ   nonexistent_schemarQ   )r   r=   ry   r*   rz   r{   r|   s     r?   !test_has_table_nonexistent_schemaz.HasTableTest.test_has_table_nonexistent_schema   s    Y__ 	$	!++,/C ,    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   5A!!A%(A%c                 h    t          |          }t          |                    d                     d S Nvvr   r+   r{   r}   
connectionr   s      r?   test_has_table_viewz HasTableTest.test_has_table_view   s/    z""t$$%%%%%rA   c                     t          |          }|                                 }t          |                    |                     d S N)r   ri   r+   r{   )r}   r   r   ri   s       r?   test_has_table_temp_tablez&HasTableTest.test_has_table_temp_table   s@    z""..00//00000rA   c                 h    t          |          }t          |                    d                     d S N
user_tmp_vr   r   s      r?   test_has_table_temp_viewz%HasTableTest.test_has_table_temp_view   s1     z""|,,-----rA   c                 ~    t          |          }t          |                    dt          j                             d S r   )r   r+   r{   r   rU   r   s      r?   test_has_table_view_schemaz'HasTableTest.test_has_table_view_schema   s6     z""tV%78899999rA   N)rB   rC   rD   __backend__rE   r\   rW   ri   rY   r   r   r   rS   rT   r   r   viewsr   rX   r   rV   rr   r   r   rF   rA   r?   rH   rH   J   s       K- - [-*   [* 
 
 [

 O O [O0M M M     $    & & & $1 1 %$1
 $%%. . &% &% %$. : :  : : :rA   rH   c                       e Zd ZdZdZed             Z ej        ddd          Z	d Z
e	d	             Zej        j        e	d
                         ZdS )HasIndexTestT)index_reflectionc                    t          d|t          dt          d          t          dt          d                    t          dt          d                              }t	          d|j        j                   t          j        j	        j
        rjt          d|t          dt          d          t          dt          d                    t          j        	          }t	          d
|j        j                   d S d S )NrJ   rK   TrL   rN   rO   data2my_idxrQ   my_idx_s)r   r   r   r   r%   crN   r   rS   rT   r8   r   rU   )r>   r[   tts      r?   r\   zHasIndexTest.define_tables   s    4d33366"::&&7F2JJ''
 
 	h	"""#+ 	)tW$777vvbzz**)  B *bdi(((((	) 	)rA   rz   	inspectorkindargnamesc                 B    |dk    rfdS t                    j        S )Nrz   c                  B    t          j        j        j        g| R i |S r   )r   r=   rz   	has_index)akr~   s     r?   <lambda>z)HasIndexTest._has_index.<locals>.<lambda>   s'    69#4#>t#Ma#M#M#M1#M#M rA   )r   r   )r}   r   r~   s     `r?   
_has_indexzHasIndexTest._has_index   s,    9MMMMM4==**rA   c           	      H   |                      ||          } |dd          sJ  |dd          rJ  |dd          rJ  |dd          rJ  |dd          rJ  |dd          rJ t          d| j        j        j        j                  }t          d|t          d	t                    t          dd	                    }|	                    |           |	                    |           	 |d
k    r5 |dd          rJ  |dd          rJ |j
                                          |dd          du sJ  |dd          du sJ 	 |                    |           |                    |           d S # |                    |           |                    |           w xY w)NrJ   r   r   rx   nonexistent_idxmy_idx_2test_table_2my_idx_3foor   T)r   r%   tablesrJ   r   r   r   r   r   r   __self__r   r   )r}   r   r   r[   methidxtbls          r?   test_has_indexzHasIndexTest.test_has_index  s   tZ00tL(+++++4j111114+X666664&7888884j111114
33333J 6 8 >??5'""*e$$	
 
 	

:

:		!{""4j999994
;;;;;))+++4j11T99994
33t;;;;;HHZ   HHZ      HHZ   HHZ    s   -AE5 5,F!c                    |                      ||          } |ddt          j                  sJ  |ddt          j                  rJ  |ddt          j                  rJ  |ddt          j                  rJ d S )NrJ   r   rQ   r   rx   nonexistent_idx_s)r   r   rU   )r}   r   r   r   s       r?   test_has_index_schemaz"HasIndexTest.test_has_index_schema  s     tZ00tL*V5GHHHHHH4hv7IJJJJJJ4F4F
 
 
 	
 	
 	
 4-f6H
 
 
 	
 	
 	
 	
 	
rA   N)rB   rC   rD   r   __requires__rE   r\   r   combinationsr   r   r   rS   rT   r   rF   rA   r?   r   r      s        K(L) ) [)(  7	;HHHD+ + + 
! ! 
T!: 		
 	
 
T 	
 	
 	
rA   r   c            	           e Zd ZdZdZdZ ej        ddddd	           ej        d
ddg           ej        ddddd	          d                                     Z	dS ) BizarroCharacterFKResolutionTestztests for #10275T)!foreign_key_constraint_reflection)rK   )z(3))zcol%p)z[brack]
columnnamer   use_compositeF)plain)z(2))z
per % cent)z
[brackets]	tablenamec                    t          ||t          |t          dd          d          }|r*|                    t          dt          d                     |r}t          d|t          dt          d          t          dt                    t          d	t                    t	          j        dd	g|j        j        |j        j        g          d           nNt          d|t          dt          d          t          dt          |j        j                            d           |
                    |           t                      }t          d||
          }|j        |         }	|j        j                            |	j        d                   sJ |r,|j        j                            |	j        d                   sJ d S d S )NrK   T)keyrM   test_needs_fkid2rL   otherrefref2autoload_withr      )r   r   r   append_columnro   ForeignKeyConstraintr   rK   r   r   
create_allr   r   r   
referencesr   )
r}   r   r[   r   r   r   r   m2o2t1s
             r?   test_fk_refz,BizarroCharacterFKResolutionTest.test_fk_ref3  s    :wDdCCC	
 
 
  	GVE7EEEFFF 	tW$777ug&&vw'''"$'2489LMM"     tW$777uj1122"    	J'''ZZ7Bj999Yy!tx""247+++++ 	149''Q00000	1 	100rA   N)
rB   rC   rD   __doc__r   r   r   r   	variationr   rF   rA   r?   r   r   -  s        K9LW:|l   Wu66W  (1 (1  76 (1 (1 (1rA   r   c                      e Zd ZdZdZed             Zd Zed             Zee	j
        j        d                         Zed             Zed             Zee	j
        j        d	                         Zee	j
        j        d
                         Zee	j
        j        d                         Zee	j
        j        d                         Zee	j
        j        d                         ZdS )QuotedNameArgumentTestonceTc                 0   t          d|t          dt                    t          dt          d                    t          dt          d                    t          dt                    t	          j        dd          t	          j        d	d          t	          j        dd
          t	          j        dgdgd          t	          j	        dd          dd           t          j        j        j        rt          d|t          dt                    t          dt          d                    t          dt          d                    t          dt                    t	          j        dd          t	          j        dd          t	          j        dd          t	          j        dgdgd          t	          j	        dd          dd           t          d|t          dt          d          t          dt                    d           t          j        j        j        rt          j        j        j        rddg}ndg}|D ]}dt          j        j        j                            d|z            dt          j        j        j                            |          }t)          j        |dt-          |                     t)          j        |d t-          d!t          j        j        j                            d|z            z                       d S d S )"Nquote ' onerK   rl   rO   rN   
related_idzpk quote ' onerl   zix quote ' onezuq quote' onez
related.idzfk quote ' onezname != 'foo'zck quote ' onezquote ' one commentT)commentr   quote " twozpk quote " twozix quote " twozuq quote" twozfk quote " twozck quote " two zquote " two commentrelatedrL   r   r`   view %s AS SELECT * FROM r^   r_   zDROP VIEW %s)r   r   r   r   ro   PrimaryKeyConstraintr%   UniqueConstraintr   CheckConstraintr   rS   symbol_names_w_double_quoter8   view_column_reflectionr   r=   rz   identifier_preparerquoter   ra   r$   )r>   r[   namesrl   rb   s        r?   r\   z$QuotedNameArgumentTest.define_tablesm  s7   4!!66"::&&66"::&&<))#D/?@@@H%v..$   #-=   5EFFF.%	
 	
 	
 	
* 7? 	tW%%vvbzz**vvbzz**|W--'3CDDD)622#(   'F\N1A   "?9JKKK2"%   * 	4d3339g&&	
 	
 	
 	
 2: 	;C !! "   I%9??!D(    I%9??EEE	 X~s5zzBBB!& )+?EE%,  	 	 	 	'	 	 rA   c                 `     t          j        ddt           j        j        f          |           S )N)r   r   )r   r   rS   r   )fns    r?   quote_fixturesz%QuotedNameArgumentTest.quote_fixtures  s;    
w#G,HI
 
   	rA   c                 Z   t          t          j                  }t          j        j        j        r9|                    |          }t          t          |t                               d S t          t                    5  |                    |          }d d d            d S # 1 swxY w Y   d S r   )r   r   r=   r   rS   reflect_table_optionsr8   get_table_optionsr+   
isinstancer;   r   NotImplementedError)r}   rl   r   ress       r?   test_get_table_optionsz-QuotedNameArgumentTest.test_get_table_options  s    vy!!19 	3((..CJsD))*****233 3 3,,T223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   =B  B$'B$c                 l    t          t          j                  }|                    d|z            sJ d S )Nr   )r   r   r=   get_view_definitionr}   rl   r   s      r?   test_get_view_definitionz/QuotedNameArgumentTest.test_get_view_definition  s8     vy!!''	D(89999999rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_columnsr  s      r?   test_get_columnsz'QuotedNameArgumentTest.test_get_columns  s1    vy!!%%%%%%%rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_pk_constraintr  s      r?   test_get_pk_constraintz-QuotedNameArgumentTest.test_get_pk_constraint  s1    vy!!%%d+++++++rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_foreign_keysr  s      r?   test_get_foreign_keysz,QuotedNameArgumentTest.test_get_foreign_keys  s3     vy!!$$T*******rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_indexesr  s      r?   test_get_indexesz'QuotedNameArgumentTest.test_get_indexes  s3     vy!!%%%%%%%rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_unique_constraintsr  s      r?   test_get_unique_constraintsz2QuotedNameArgumentTest.test_get_unique_constraints  s3     vy!!**40000000rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_table_commentr  s      r?   test_get_table_commentz-QuotedNameArgumentTest.test_get_table_comment  s3     vy!!%%d+++++++rA   c                 f    t          t          j                  }|                    |          sJ d S r   )r   r   r=   get_check_constraintsr  s      r?   test_get_check_constraintsz1QuotedNameArgumentTest.test_get_check_constraints  s3     vy!!))$///////rA   N)rB   rC   rD   run_create_tablesr   rE   r\   r   r   r   rS   r   r  r  r  r   r  r   r  unique_constraint_reflectionr  comment_reflectionr  check_constraint_reflectionr  rF   rA   r?   r   r   i  s       KP P [Pd   3 3 ^3 ,: : -, ^: & & ^& , , ^, 7+ + 87 ^+ && & '& ^& 21 1 32 ^1 (, , )( ^, 10 0 21 ^0 0 0rA   r   c           
      2   t          j        d d t           j        j        fd          }t          j        t          j        t          j        t          j        d          }t          j        t          j	        t          j
        t          j        t          j        t          j        t          j	        t          j
        z  t          j	        t          j        z  d          }t          j        ddd          } | | | ||                                         S )	Nc                      t           j        S r   )r   rU   rF   rA   r?   r   z$_multi_combination.<locals>.<lambda>  s	    F& rA   rR   r   r4   r   TF
use_filter)r   r   rS   rT   r!   DEFAULT	TEMPORARYANYr    TABLEVIEWMATERIALIZED_VIEWANY_VIEW)r   rR   r4   r   filter_namess        r?   _multi_combinationr'     s    !&&$	
   F  	  E $:?*:77	 	 	D 'elKKKL6%%\\"--..//000rA   c                   $   e Zd ZdxZZdZed             Zed             Zed             Z	ed             Z
ed             Zd Zd	 Zd
 Zdej        ej        dfdZdej        ej        dfdZdej        ej        dfdZed             Zdej        ej        dfdZed             Zdej        ej        dfdZed             Zdej        ej        dfdZed             Zdej        ej        ddfdZed             Zdej        ej        dfdZed             Z e!j"        j#        d             Z$e!j"        j#        d             Z%e!j"        j#        d             Z&e!j"        j#        d             Z'e!j"        j#        e!j"        j(        d                         Z)e!j"        j#        d             Z*e!j"        j#        d              Z+ e!j,        dd!e!j"        j-        fd"#           e!j,        de!j"        j.        fdd$#          d%                         Z/ e!j,        de!j"        j.        fdd$#          d&             Z0e!j"        j1        d'             Z2e!j"        j3        e!j"        j4        d(                         Z5e!j"        j6        d)             Z7e!j"        j6        e!j"        j.        d*                         Z8d_d+Z9 e!j,        d,dde!j"        j.        fdde!j"        j3        fdde!j"        j.        e!j"        j3        z   fd-#          d.             Z:e!j"        j;        d/             Z<e!j"        j;        d0             Z=e!j"        j;        e!j"        j>        e!j"        j4        d1                                     Z? e!j,        d2de!j"        j.        fd$#          e!j"        j@        d3                         ZA e!j,        d2de!j"        j.        fd$#          e!j"        j-        d4                         ZBe!j"        jC        e!j"        j.        d5                         ZD e!j,        d2de!j"        j.        fd$#          e!j"        jE        d6                         ZF e!j,        d7d8d9#          e!j"        jE        e!j"        jG        e!j"        jH        d:                                                 ZIe!j"        j;        e!j"        jJ        d;                         ZKe!j"        jL        d<             ZM e!j,        de!j"        j.        fd2d$#          e!j"        jJ        d=                         ZNe!j"        j3         e!j,        d2de!j"        j.        fd$#          d>                         ZOe!j"        j3        d?             ZPe!j"        jQ        d@             ZR e!j,        de!j"        j.        fd2d$#          dA             ZS e!j,        de!j"        j.        fd          dB             ZTe!jU        dC             ZVe!j"        jW        eXdD                         ZYe!j"        j6        eXdE                         ZZdF Z[d`dGZ\dadHZ]eXdI             Z^e!j"        j@        eXdJ                         Z_dK Z`e!j"        j-        eXdL                         Zae!j"        jE        eXdM                         Zbe!j"        jJ        eXdN                         Zce!j"        jd        eXdO                         Ze e!j,        dPe!j"        jW        fdQdRe!j"        j@        fdSe!j"        j-        fdTe!j"        jE        fdUe!j"        jJ        fdVe!j"        jd        fdWe!j"        j6        fdX#	  	        dY             ZfdZ Zg e!j,        ddd$#           e!j,        de!j"        jh        fdd[#          d\                         Zie!j"        j6        d]             Zje!j"        jk        d^             ZldS )bComponentReflectionTestNTc                     |                      |d            t          j        j        j        r'|                      |t          j        j                   d S d S r   )define_reflected_tablesr   rS   rT   r8   r   rU   rZ   s     r?   r\   z%ComponentReflectionTest.define_tables#  sW    ##Hd333#+ 	N'''.2LMMMMM	N 	NrA   c                    |r|dz   }nd}t           j        j        j        rt	          d|z  d          f}nd}t          d|t          dt          j        d	
          t          dt          j	        d          d          t          dt          j
                    d          t          dt          j        g|R  t          j        ddd          t          j        d          |d	
  
        }t          d|t          dt          j        d	
          t          dt          j        t	          d|z  dd                    t          dt          j        t	          d|z                      t          dt          j        d          d	           t          j        d!d"          t          j        ddd#d$          |d	
  
         t          d%|t          dt          j                  t          d&t          j        t	          |j        j                            t          d't          j        d(          d	)          t          j        dd*d+          |d	           t          d,|t          d-t          j        d	d./          t          dt          j        d(          d01          t          d2t          j        d(          d31          t          d4t          j        d5          d61          |d78           t          d9|t          dt          j        d(                    |d:8           t           j        j        j        re|t          d;|t          d-t          j        d	
          t          dt          j        d(                    t          d<t	          d=t           j        j        z                      d	t&          j        j        j        >           nt          d?|t          d-t          j        d	
          t          d@t	          dAt&          j        j        j        z                      t          dt          j        d(                    |d	           t          dB|t          d-t          j        d	
          t          dt          j        d(                    |d	           t           j        j        j        r_t3          dC|j        j        |j        j        d	            t3          dD|j        j        |j        j        |j        j                   |st          dE|t          dFt          j        d                    d	G          }t          dH|t          d-t          j        d	
          t          dFt          j        d                    d	G          }t           j        j        j        rnt           j        j        j        rXt3          dI|j        j                                                   t3          dJ|j        j                                                   t           j        j         j        r| !                    ||           |s-t           j        j"        j        r| #                    |           d S d S d S )KN. z%susers.user_id
user_id_fkr   rF   usersuser_idTrL   test1   Fnullabletest2parent_user_id	test2 > 0zz_test2_gt_zerousers check constraintrl   r   test2 <= 1000rR   r   
dingalingsdingaling_id
address_idz%semail_addresses.address_idzz_email_add_id_fgdi fk commentid_userrN      )uniquez$address_id > 0 AND address_id < 1000address_id_gt_zerozz_dingalings_multipledi unique commentemail_addressesremote_user_idemail_address   )indexemail_ad_pkea pk commentcomment_testrK   
id comment)rM   r   data % commentr   d2)Comment types type speedily ' " \ '' Fun!d3*   Comment
withescapesthe test % ' " \ table comment)rR   r   no_constraints"no
constraintshasescapedcommentlocal_table	remote_idz%s.remote_table_2.id)r   rR   remote_tablelocal_idz%s.local_table.idremote_table_2users_t_idxusers_all_idxnoncol_idx_test_nopkqr   noncol_idx_test_pknoncol_idx_nopknoncol_idx_pk)$r   rS   self_referential_foreign_keysr8   r   r   r   ro   rp   CHARFloatr   r   r   r   r   r1  r   cross_schema_fk_reflectionr   rU   r=   rz   default_schema_namer   r%   r2  r6  indexes_with_ascdescreflect_indexes_with_ascdescrd  descr   rW   temp_table_reflectionrY   )r>   r[   rR   schema_prefixparent_id_argsr0  rc  re  s           r?   r+  z/ComponentReflectionTest.define_reflected_tables)  sy    	"SLMMM9A 	 %5L  NN  N9bf$7777BGAJJ7777BHJJ777#RZA.AAA'0  
 //
 
 
" 	>2:4@@@
2]B-+    
,}<== 
 629R==6666)   -+	   =	
 	
 	
 	
@ 	<,,#RZEGO1L1LMM?BIbMM>>>#=/   	
 	
 	
 	
 	4|LLL629R==2BCCC	"H  
 420HIII9	
 	
 	
 	
 	629R==))<	
 	
 	
 	
 6> '	~!4>>>629R==11#"2W^5OO   #'!9,@     "4>>>""/$i/CD   629R==11!"&    $4>>>629R==11!"&    ,4 	J-dKKKK%'-    J',*3	!--"&	( ( ($ &+(4>>>3	!--"&& & &" $9AJ(EMJ +-A-C-E-J-J-L-LMMM/+=+?+A+F+F+H+HIII2: 	/Xv... 	-'*@H 	-""8,,,,,	- 	- 	- 	-rA   c                 \    t          t          t          j        dt          j                   S rd   rf   rh   s    r?   ri   z'ComponentReflectionTest.temp_table_name  rj   rA   c                    t          t          t          j                  }|                                 }t	          ||t          dt          j        d          t          dt          j        d                    t          dt          j                  t          j	        ddt          j
                   t          j        d	d          fi |}t          j        j        j        rkt          j        j        j        rWt#          j        |d
t'          dt          j
        z                       t#          j        |dt'          d                     d S d S d S )NrK   TrL   rl   rO   r   user_tmp_uq_r   user_tmp_ixr^   rm   r_   rn   )r   r   r=   ri   r   r   ro   rp   rq   r   rg   r%   r   rS   rV   r8   rr   r   ra   r$   rs   s        r?   rY   z*ComponentReflectionTest.define_temp_tables  sJ   $VVY77((**
4T22262:b>>**5"&!! -JFL-J-JKKKH]E**
 
 
 
" ,4	O 08	O L028,?    L=#6L2M2MNNNNN	O 	O 	O 	OrA   c                    t           j        j        j        rdh}nt	                      }dD ]}|}|r| d| }|dz   }||v rdnd}d| d| d	| }t          j        |d
t          |                     ||v rKd}	|rt          j        d          r| d|	 }	d|	 d| d}
t          j        |d
t          |
                     t          j        |dt          d| d|                      d S )Nr>  r0  rI  r>  r-  _vzMATERIALIZED r.  zCREATE zVIEW r   r^   	mat_indexoraclezCREATE INDEX z ON z(data)r_   zDROP )	r   rS   materialized_viewsr8   setr   ra   r$   against)r>   r[   rR   materializedru   fullname	view_nameprefixrb   
index_namer   s              r?   rW   z$ComponentReflectionTest.define_views  s]   .6 	!(>LL55LD 	 	J!H 4$33z33 4I(2l(B(B__FN&NNyNNHNN  L>3u::>>>\))(
 :goh77 :$*!9!9Z!9!9JGjGGiGGGX~s3xx@@@L--MV-M-M)-M-M)N)N   #	 	rA   c                     i }t           j        |v r|                    |           t           j        |v r|                    |           t           j        |v r|                    |           |S r   )r    r"  updater#  r$  )r}   r   r   r   r  r   s         r?   _resolve_kindz%ComponentReflectionTest._resolve_kind  sk    t##JJv?d""JJu'4//JJ|$$$
rA   c                    t           j        j        j        s*|                                 |                                 d S t           j        j        j        s+|                    |           |                                 d S d S r   )r   rS   r   r8   clearr|  r  )r}   r   r  s      r?   _resolve_viewsz&ComponentReflectionTest._resolve_views$  s{    6> 	!   KKMMMMM!4< 	!LL&&&     	! 	!rA   c           	      4   d |t           j        u rd |t           j        u rd d ddht          j        j        dddd	|                                 hit          j        j        j	        sGd          
                    d           t          j        j                                     ddg           t          j        j        j	        sd                              ddg           t          j        j        j	        rt          j        j        j	        s/d                              d	|                                 g           t          j        j        j	        sd                              d	g           fd
|                                D             }|S )Nc                     dS )NTrF   )_s    r?   r   z8ComponentReflectionTest._resolve_names.<locals>.<lambda>-  s     rA   c                     d| d         vS Ntmpr   rF   r   s    r?   r   z8ComponentReflectionTest._resolve_names.<locals>.<lambda>/  s    U!A$%6 rA   c                     d| d         v S r  rF   r  s    r?   r   z8ComponentReflectionTest._resolve_names.<locals>.<lambda>1  s    Uad] rA   r^  r`  r\  rc  re  r   c                 j    i | ]/\  }} |          r|d                   vrr
|d          v ,||0S )r   rF   ).0r   vr&  removedrR   scope_filters      r?   
<dictcomp>z:ComponentReflectionTest._resolve_names.<locals>.<dictcomp>N  sg     
 
 
1|A
 !GFO++! ,%&qT\%9%9	 q &:%9%9rA   )r!   r  r   r   r   rU   ri   rS   rk  r8   addr  r   rp  temp_table_namesrr   items)r}   rR   r4   r&  valuesr   r  r  s    ` `  @@r?   _resolve_namesz&ComponentReflectionTest._resolve_names,  s   %~K'''66LK)))22L >#34N&&$$$&&)	
 :B 	DMm,,,GN./66!12   08 	DM  ')=>    6>	I#4<	I DM  ,0D0D0F0F!GHHH/7 	1DM  ,000
 
 
 
 
 
 

 
 
 
rA   c                 f   |dft           j        i}|dft           j        |dft           j        |dft           j        i}|                     ||           |dft           j        |dft           j        |dft           j        |dft           j        |d	ft           j        |d
ft           j        |dft           j        |dft           j        |dft           j        |dft           j        ||                                 ft           j        i}|                     ||||          }|                     ||||          }|S )Ndingalings_vemail_addresses_vusers_vr   r0  r>  rI  rP  rZ  r\  r^  r`  rc  re  r,   r!  r  ri   r  r  )	r}   rR   r4   r   r&  r  r   r   r   s	            r?   exp_optionsz#ComponentReflectionTest.exp_optionsW  s.     0$(;()48Y\"DH

 	E<000Wtx\"DH&'^$dh%&]#TX^$dh%&+,dh)*DHT))++,dh
   vulCC!!&%sCC
rA   c                 J   dd i}|df|i}|df||df||df|i}|                      ||           |df||df||df||d	fdd
i|dfddi|df||df||df||df||df|||                                 f|i}|                     ||||          }	|                     ||||	          }	|	S )Ntextr  r  r  r   r0  r>  rI  rP  rY  rZ  r[  r\  r^  r`  rc  re  )r  ri   r  r  )
r}   rR   r4   r   r&  emptyr  r   r   r   s
             r?   exp_commentsz$ComponentReflectionTest.exp_commentsv  s/    0%8()5Y\"E

 	E<000Wu\"E&'^$=' %&@) ]#U^$e%&+,e)*ET))++,e
"   vulCC!!&%sCC
rA   c                   
 dt           j        d dfd

fd}|df 
ddt           j                   
d	           
d
           
d          gi}|df 
d	dt           j                   
d           
d          g|df 
ddt           j                   
dt           j                   
dt           j                   
d          g|df 
ddt           j                   
d           
d          gi}|                     ||           |df |d           
dd           
dd           
d          g|df |d           
d	           
d
           
d          g|df |d	           
d           
d          g|df |dd           
dd           
d d!           
d"d#          g|d$f 
d          g|d%f |d           
d           
d&          g|d'f |d           
d(           
d          g|d)f |d           
d          g|d*f 
d+          g|d,f |d           
d+          g||                                 f |d           
d           
d          gi}|                     ||||          }	|                     ||||	          }	|	S )-NFTc                 b    | |t           j        |||d}|dk    r|                    d           |S )N)rl   autoincrementtypedefaultr   r5  omitr  )r,   r!  pop)rl   autor  r   r5  r   s         r?   r   z0ComponentReflectionTest.exp_columns.<locals>.col  sF     !%""$ C v~~(((JrA   c                 :    dt           j        dd|} | fi |S )NTF)r  r  r5  r,   r!  )rl   rt   r   s     r?   pkz/ComponentReflectionTest.exp_columns.<locals>.pk  s-    48MM"MB3t??r??"rA   r  r?  r  )r  r5  r@  rC  rN   r  rJ  rK  r  r1  r2  r4  r6  r7  r   rK   rl   r   r0  r>  rI  rP  rQ  rS  rR  rT  rU  rV  rX  rZ  r\  r]  r^  r_  r`  rc  rd  re  r  )r}   rR   r4   r   r&  r  r  r   r   r   r   s             @r?   exp_columnsz#ComponentReflectionTest.exp_columns  s    dht	 	 	 		# 	# 	# 	# 	#
 ^$N$(CCCL!!IF	'
 ()LvAAA$%%O$$,
 YIFTX>>>Gdh///Gdh///$%%	" \"Dv999FE

%
$ 	E<000W9Ge,,,Ge,,,$%%	  \">""L!!IF	% &'<  $%%O$$*
 ^$4...F$4555L   D":;;;' %&V]#bbhhFSS=M=M%N^$rr$xxZ##f++&N%&D33v;;(?+,ss3xxj)*RRXXss3xx,@T))++,4FE

/C&
N   vulCC!!&%sCC
rA   c                 
    h dS )N>   rl   r  r  r5  rF   r}   s    r?   _required_column_keysz-ComponentReflectionTest._required_column_keys  s    6666rA   c                    t           j        d dd} |d           }t          j        j        j        r|df |d          i}n|df|i}|df||df||df|i}|                     ||           |d	f |d
          |df |d          |df |ddd          |df |d          |df||df |d          |df |d          |df |d          |df||df |d          ||                                 f |d          i}	t          j        j        j        s.|		                                D ]}
|
d         t           j        |
d<   | 
                    ||	||          }|                     ||||          }|S )Nr;  c                 (    t          |          | |dS )N)constrained_columnsrl   r   )list)rl   r   colss      r?   r  z+ComponentReflectionTest.exp_pks.<locals>.pk  s     '+Dzz"  rA   r   r  r?  r  r  r   r0  r1  r>  rI  r@  rN  rO  rP  rK   rZ  r\  r^  r`  rc  re  rl   )r,   r!  r   rS   materialized_views_reflect_pkr8   r  ri   reflects_pk_namesr  r  r  )r}   rR   r4   r   r&  r  r  r  r   r   valr   s               r?   exp_pkszComponentReflectionTest.exp_pks  s     8T 	 	 	 	 	 9A 	=#^4bb6H6HILL#^4e<L()5Y\"E

 	E<000Wrr)}}\"BB~$6$6&'=/* * * ^$bbhh%&]#RRXX^$bbhh%&4+,e)*BBtHHT))++,bbhh
 19 	+}} + +v;*"&(CK  vulCC!!&%sCC
rA   c                 
    ddhS )Nrl   r  rF   r  s    r?   _required_pk_keysz)ComponentReflectionTest._required_pk_keys.  s    -..rA   c                 X    G d d          |t           j        d ffd	}|dfg i}|dfg |dfg |dfg i}|                     ||           |df |d	gd
gdd          g|df |dgd
gd           |dgdgddd          g|df |dgd
gd          g|dfg |dfg |df |dgdgdt          j                  g|df |dgdgdd           g|dfg |dfg |dfg ||                                 fg i}t          j        j        j	        s||df         
                                 t          j        j        j	        s?|                                D ]*}	|	D ]%}
|
d          t           j        urt           j        |
d <   &+|                     ||||          }|                     ||||          }|S )!Nc                       e Zd Zd ZdS )+ComponentReflectionTest.exp_fks.<locals>.ttc                 >    |d u pt           j        j        j        |k    S r   )r   r=   rz   rl  )r}   r   s     r?   __eq__z2ComponentReflectionTest.exp_fks.<locals>.tt.__eq__:  s$    TM Fy(<ErA   NrB   rC   rD   r  rF   rA   r?   r   r  9  s#            rA   r   c                 D    | ||t           j        ||n	             ||dS )N)r  referred_columnsrl   r5   referred_schemareferred_tabler   r  )r  ref_col	ref_table
ref_schemarl   r   r   s         r?   fkz+ComponentReflectionTest.exp_fks.<locals>.fk@  s:     (,$+8","8JJbbdd"+"
 
 
rA   r  r  r  r   r0  r7  r1  r/  r   r>  rC  r@  rI  rA  rB  r;  rJ  rP  rZ  r\  r]  rK   r`  )r  r^  r_  rc  re  rl   )r,   r!  r  r   rU   ri   r   rS   rh  r8   r  named_constraintsr  r  r  )r}   rR   r4   r   r&  r  r  r   r   valsr  r   r   s               @r?   exp_fkszComponentReflectionTest.exp_fks2  s   	 	 	 	 	 	 	 	 	 	 	 	 	 	(  0"5()2Y\"B

 	E<000W$%	{G,OOO  \"I;W55!N!N%-+  	% &'$%	{G<<* ^$b%&]# MF$%1	  & ^$J<$4HHH' %&+,b)*BT))++,bC"
F =E 	.FG$%++---19 	/ / / / /C6{$(22&*hF/   vulCC!!&%sCC
rA   c                 
    h dS )N>   rl   r  r  r  r  rF   r  s    r?   _required_fk_keysz)ComponentReflectionTest._required_fk_keys  s    
 
 
 	
rA   c                    dd dddd}|dfg i}|dfg |dfg |dfg i}|                      ||           |r(||df                              |dd	
                     |dfg  |ddd           |dddd
           |dddd          |dfg  |dt          j        dd           |dt          j        d           |ddddd          |dfg  |dt          j        
           |dt          j        d          |dfg |d fg |d!fg  |d"t          j        d          |d#fg  |d$t          j        d          |d%fg |d&fg  |d'd(d'd)i*          |d+fg  |d'd,d'd)i*          ||                                 fg  |d-d.
           |d/d0t
          j         dd1          i}t          j        j	        j
        rt          j        j        j
        s8||d&f                                          ||d+f                                          |                     ||||          }	|                     ||||	          }	|	S )2NF)rE  column_sorting
duplicatesr  c                 <   t           j        j        }t           j        j        }t           j        j        }|r|j        r	|r	|j        sdS |t          |          | t          j        g d}	r*|	d<   |j        r|	d         x|	d<   }
fd|
D             |	d<   |r| |	d<   |	gS )NrF   )rE  column_namesrl   dialect_optionsinclude_columnsr  r  expressionsc                      g | ]
}|v rd n|S r   rF   )r  r   r  s     r?   
<listcomp>zDComponentReflectionTest.exp_indexes.<locals>.idx.<locals>.<listcomp>  s4     + + +?@^ 3 3+ + +rA   duplicates_constraint)	r   rS   foreign_keys_reflect_as_index#unique_constraints_reflect_as_index*reflect_indexes_with_ascdesc_as_expressionr8   r  r,   r!  )rl   rE  r  r  r  r  fk_reqdup_reqsorting_expressionr   origs     `        r?   r   z0ComponentReflectionTest.exp_indexes.<locals>.idx  s     %CF&JG K   6> #*? r  $T

#'8#% C  (6$%%- 03N0CCC&+ + + +DH+ + +C'  4/3+,5LrA   r  r  r  r   rN   rz  r   r0  r7  r/  T)rl   r  r1  r6  r2  rb  ra  )rl   rE  r>  )rl   rE  r  rC  r@  r?  rG  rI  rK  rJ  rP  rZ  r\  r]  r^  r_  r`  rc  rd  rf  )ro  )rl   r  re  rg  r   rv  rl   ru  )rl   r  rE  )r  extendr,   r!  ri   r   rg   r   rS   rm  r8   rn  r  r  r  )
r}   rR   r4   r   r&  r   r  r   r   r   s
             r?   exp_indexesz#ComponentReflectionTest.exp_indexes  s    #	 #	 #	 #	 #	J  0"5()2Y\"B

 	E<000 	&.1299F---   W  %LTBBB YGGG  WgM$GGG 
 \" 
%V$(4DIII
%YTX$777
%  "1#  
% &' *_48444*%DH>>>* ^$b%&]# &[txD999& ^$ 'Zdh4888' %&+, /*$'#3  / )* -osI>N  -
 T))++, /U////666#	  /U3
j  5=	;#@H	; F234::<<<F01288:::  vulCC!!&%sCC
rA   c                 
    h dS )N>   rl   rE  r  rF   r  s    r?   _required_index_keysz,ComponentReflectionTest._required_index_keys	  s    1111rA   Fc                    d dd dd}|dfg i}|dfg |dfg |dfg i}|                      ||           |dfg  |d	d
ddd          |dfg  |dt          j        t          j                   |ddddd          |dfg |dfg |dfg |dfg |dfg |dfg |dfg |dfg ||                                 fg  |ddt          j                    i}	|ri |||	S |                     ||	||          }
|                     ||||
          }
|
S )!NF)duplicates_indexis_indexr   c                 t    t           j        j        }|r	|j        sdS t	          |          | |d}|r||d<   |gS )NrF   )r  rl   r   r  )r   rS   *unique_index_reflect_as_unique_constraintsr8   r  )rl   r  r  r   r  reqr   s          r?   ucz+ComponentReflectionTest.exp_ucs.<locals>.uc  s\     "MC  r $T

" C
   ;*:&'5LrA   r  r  r  r   r0  r2  r6  ra  T)rl   r  r  r>  rN   )rl   r  r@  r?  rG  rH  )rl   r  r   rI  rP  rZ  r\  r^  r`  rc  re  rl   ru  r   )r  r,   r!  ri   r   rg   r  r  )r}   rR   r4   r   r&  all_r  r  r   r   r   s              r?   exp_ucszComponentReflectionTest.exp_ucs  s    +/	 	 	 	 	  0"5()2Y\"B

 	E<000W  &%2!    \" 	%FDHEEE	% "1%=/  	% &'^$b%&]#R^$b%&+,b)*BT))++, /F!>!>!>???/9
@  	6l6e6v66$$T65,GGC%%fe\3GGCJrA   c                 
    ddhS )Nrl   r  rF   r  s    r?   _required_unique_cst_keysz1ComponentReflectionTest._required_unique_cst_keysR  s    ''rA   c                   
  G d dt                     
d
fd	}|dfg i}|dfg |dfg |dfg i}|                     ||           |df |d	t          j                   |d
dd          g|df |dd          g|dfg |dfg |dfg |dfg |dfg |dfg |dfg |dfg ||                                 fg i}|                     ||||          }	|                     ||||	          }	|	S )Nc                       e Zd Zd ZdS )+ComponentReflectionTest.exp_ccs.<locals>.ttc                     |                                                     dd                              dd                              dd          }| |v S )N(r.  )`)lowerreplace)r}   r   r   s      r?   r  z2ComponentReflectionTest.exp_ccs.<locals>.tt.__eq__^  sK    KKMMWS"%%WS"%%WS"%%	  s{"rA   Nr  rF   rA   r?   r   r  ]  s#        # # # # #rA   r   c                 "     |           ||dS )N)sqltextrl   r   rF   )r  rl   r   r   s      r?   ccz+ComponentReflectionTest.exp_ccs.<locals>.ccg  s    !r$xx'JJJrA   r  r  r  r   r0  r<  r8  r9  r:  rS  r>  z$address_id > 0 and address_id < 1000rF  r   rI  rP  rZ  r\  r^  r`  rc  re  r   )strr  r,   r!  ri   r  r  )r}   rR   r4   r   r&  r   r  r   r   r   r   s             @r?   exp_ccszComponentReflectionTest.exp_ccsV  s   	# 	# 	# 	# 	# 	# 	# 	#	K 	K 	K 	K 	K 	K
  0"5()2Y\"B

 	E<000W?DH--&4    \":-  % &'^$b%&]#R^$b%&+,b)*BT))++,b/
2   vulCC!!&%sCC
rA   c                 
    ddhS )Nrl   r  rF   r  s    r?   _required_cc_keysz)ComponentReflectionTest._required_cc_keys  s    	""rA   c                     t          |          }t          t          j        j        |                                v            d S r   )r   r+   r   r   rU   get_schema_namesr   s      r?   test_get_schema_namesz-ComponentReflectionTest.test_get_schema_names  s9    z""*d.C.C.E.EEFFFFFrA   c                     t          |          }t          |                    t          j        j                             t          |                    d                     d S )Nsa_fake_schema_foo)r   r+   
has_schemar   r   rU   r*   r   s      r?   test_has_schemaz'ComponentReflectionTest.test_has_schema  sO    z"" :;;<<<!56677777rA   c                     |                     ddt          t          j        j        i          }t          |          }t          t          j        j        |                                v            dS )z
test #7300r   barschema_translate_mapN)execution_optionsr'   r   r   rU   r   r+   r  r   s      r?   %test_get_schema_names_w_translate_mapz=ComponentReflectionTest.test_get_schema_names_w_translate_map  sk      11ugn8" 2 
 

 z""*d.C.C.E.EEFFFFFrA   c                 &   |                     ddt          t          j        j        i          }t          |          }t          |                    t          j        j                             t          |                    d                     d S )Nr   r  r  r	  )	r  r'   r   r   rU   r   r+   r
  r*   r   s      r?   test_has_schema_w_translate_mapz7ComponentReflectionTest.test_has_schema_w_translate_map  s    11ugn8" 2 
 

 z"" :;;<<<!56677777rA   c                    t          |          }t          d|                                v            t          |                    d                     |                    t          d                     	 t          d|                                v            t          |                    d                     |                                 t          d|                                v            t          |                    d                     |                    t          d                     d S # |                    t          d                     w xY w)Nfoo_barzCREATE SCHEMA foo_barzDROP SCHEMA foo_bar)r   r*   r  r
  executer$   r   r+   r   s      r?   test_schema_cachez)ComponentReflectionTest.test_schema_cache  s6    z""d33555666++,,,3677888	;Y$"7"7"9"99:::T__Y//000I!6!6!8!88999DOOI..///s#899:::::Js#899::::s   8BD: :$Ec                 x    t          j                    }t          |           t          |j        d          sJ d S )Nrl  )r   r:   r   hasattrrz   )r}   engines     r?   test_dialect_initializez/ComponentReflectionTest.test_dialect_initialize  s:    '))v~'<=======rA   c                 b    t          |          }t          |j        |j        j                   d S r   )r   r   rl  rz   r   s      r?   test_get_default_schema_namez4ComponentReflectionTest.test_get_default_schema_name  s.    z""D$j&8&LMMMMMrA   foreign_keyorder_byr   
use_schemac                 T  	 |rt           j        }nd }h d	t          |          }|r d |                    |          D             }n|                    |          }	fd|D             }|dk    rg d}t          ||           d S g d}t          t          |          |           d S )N>   r\  rP  r^  rZ  r`  re  rc  c                 .    g | ]}|d          
|d          S )r   rF   )r  recs     r?   r  z@ComponentReflectionTest.test_get_table_names.<locals>.<listcomp>  s6       q6A  rA   c                     g | ]}|v|	S rF   rF   )r  t_ignore_tabless     r?   r  z@ComponentReflectionTest.test_get_table_names.<locals>.<listcomp>  s#    DDDQA^,C,Cq,C,C,CrA   r  rx  )r>  rI  r0  )r   rU   r   get_sorted_table_and_fkc_namesget_table_namesr   sorted)
r}   r   r  r   rR   r   r   table_namesanswerr&  s
            @r?   test_get_table_namesz,ComponentReflectionTest.test_get_table_names  s      	'FFF
 
 
 z"" 	2 >>vFF  FF ))&11FDDDD&DDD}$$???FV$$$$$???F{##V,,,,,rA   c                 h   t          |          }|rt          j        }nd }|                    |          }t          j        j        j        rEt          t          |          ddg           t          |
                    |          dg           d S g d}t          t          |          |           d S )Nr  r  r  )r  r  r  )r   r   rU   get_view_namesr   rS   r|  r8   r   r)  get_materialized_view_names)r}   r   r   r   rR   r*  r+  s          r?   test_get_view_namesz+ComponentReflectionTest.test_get_view_names  s     z"" 	'FFF))&11.6 	-{##&99%EFFF0088>:JKKKKKEEEF{##V,,,,,rA   c                     t          |          }|                                }t          t          |          dt          j         g           d S rd   )r   get_temp_table_namesr   r)  r   rg   r}   r   r   r  s       r?   test_get_temp_table_namesz1ComponentReflectionTest.test_get_temp_table_names  sN    z""4466F#$$'A6<'A'A&BCCCCCrA   c                     t          |          }|                                }t          t          |          dg           d S r   )r   get_temp_view_namesr   r)  r3  s       r?   test_get_temp_view_namesz0ComponentReflectionTest.test_get_temp_view_names  sD     z""3355F#$$|n55555rA   c                 0    |                      |           d S r   )_test_get_commentsr}   r   s     r?   test_get_commentsz)ComponentReflectionTest.test_get_comments!  s    
+++++rA   c                 P    |                      |t          j        j                   d S r   )r9  r   r   rU   r:  s     r?   test_get_comments_with_schemaz5ComponentReflectionTest.test_get_comments_with_schema%  s%     	
GN,FGGGGGrA   c                    t          |          }|                     |          }t          |                    d|          ||df                    t          |                    d|          ||df                    t          |                    d|          ||df                    | j        j        j        }t          |                    ||          |||f                    d S )NrQ   rP  r0  )r   r  r   r  r   rZ  rl   )r}   r   rR   r   expno_csts         r?   r9  z*ComponentReflectionTest._test_get_comments*  s   z""v.."">&"AA()	
 	
 	

 	""76"::!"	
 	
 	

 	"">&"AA()	
 	
 	

 +0""6&"99 !	
 	
 	
 	
 	
rA   )FFzuse_views,use_schemac                    |rt           j        }nd }| j        j        | j        j        }}|rg d}nddg}t          |          }t          |||f          D ]\  }	}
|}|                    |	|          }t          t          |          dk    t          |                     t          |
j                  D ]\  }}t          |j        ||         d                    ||         d         j        }|j        }t!          |t"          j        j                  r|j        }t)          j        d          r&|t,          j        t,          j        fv rt,          j        }t          t          t3          |j                                      |j                                      t,          j        t,          j        t,          j        t,          j        t,          j        t,          j        t,          j         g                    dk    |j        d	|j        d
||         d         d	|d           |j!        s||         d         J d S )Nr  r  r  r0  rI  rQ   r   rl   r  r{  r  z), r  r  )"r   rU   r   r0  rI  r   zipr  r+   len	enumeratecolumnsr   rl   	__class__r  r   ro   r   
TypeEnginer   r~  	sql_typesDater   r}  __mro__intersectionr   NumericTimer   _BinaryrM   )r}   r   	use_viewsr   rR   r0  	addressesr*  r   ru   tableschema_namer  ir   ctype	ctype_defs                    r?   r  z(ComponentReflectionTest.test_get_columnsB  sF     	'FFF K-t{/Jy 	7JJJKK"$56Kz""!$[5)2D!E!E /	6 /	6J K##J{#CCDCIIM3t99--- $EM22 (6 (63CHd1gfo...Q1H	i)<== 4 ) 3I ?8,, /N&? 2 2 !*I
 EM**%i&788% ) 1 ) 1 ) 2 ) ) ) 0 ) 1
 
  " xxx476???EEEC#  *  679-555Q(6/	6 /	6rA   c                     |                                  }| j        |         }t          |t                      |          }|                     ||d           d S )Nr   F)strict_constraints)ri   r   r   r   assert_tables_equal)r}   r   ru   rv   reflected_user_tmps        r?   test_reflect_table_temp_tablez5ComponentReflectionTest.test_reflect_table_temp_table  sp    ))++
;z*"

*
 
 
 	  (U 	! 	
 	
 	
 	
 	
rA   c                 b   |                                  }| j        |         }t          |          }|                    |          }t	          t          |          dk    t          |                     t          |j                  D ]&\  }}t          |j	        ||         d                    'd S )Nr   rl   )
ri   r   r   r  r+   rD  rE  rF  r   rl   )r}   r   ru   rv   r   r  rT  r   s           r?   test_get_temp_table_columnsz3ComponentReflectionTest.test_get_temp_table_columns  s    ))++
;z*z""
++D		As4yy))) 011 	+ 	+FAs$q'&/****	+ 	+rA   c                     t          |          }|                    d          }t          d |D             g d           d S )Nr   c                     g | ]
}|d          S r   rF   r  r   s     r?   r  zFComponentReflectionTest.test_get_temp_view_columns.<locals>.<listcomp>  s    )))SS[)))rA   )rK   rl   r   )r   r  r   )r}   r   r   r  s       r?   test_get_temp_view_columnsz2ComponentReflectionTest.test_get_temp_view_columns  sP     z""--))D)))+@+@+@AAAAArA   )Fc                    |rt           j        j        }nd }| j        j        | j        j        }}t          |          }|                     |          }|                    |j	        |          }| 
                    |g|||j	        f         g| j                   |                    |j	        |          }	|||j	        f         d         }
t          |	d         |
           t           j        j                                        5  t          |	d         d           d d d            n# 1 swxY w Y   | j        j        j	        }| 
                    |                    ||          g|||f         g| j                   d S )NrQ   r  rl   rN  )r   r   rU   r   r0  rI  r   r  r  rl   _check_listr  r   rS   r  fail_ifrZ  )r}   r   r   rR   r0  rQ  r   r?  
users_cons	addr_consexp_colsr@  s               r?   r  z.ComponentReflectionTest.test_get_pk_constraint  s   
  	^/FFF;,dk.Iyz""ll&l))++EJv+FF
L3
345t7M	
 	
 	
 **9>&*II		/01FGI+,h777/7799 	2 	2	&!=111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 +0##F6#::;&&!"#"	
 	
 	
 	
 	
s   D((D,/D,c                 d   |rt           j        }nd }| j        j        | j        j        }}t          |          }|}t          j        j        j	        r|
                    |j        |          }|d         }	t          j        j                                        5  t          |	d         d           d d d            n# 1 swxY w Y   t          |	d         |           t          |	d         |j                   t          |	d         dg           t          |	d	         d
g           |
                    |j        |          }
|
d         }	t          j        j                                        5  t!          |	d         d u           d d d            n# 1 swxY w Y   t          |	d         |           t          |	d         |j                   t          |	d         dg           t          |	d	         dg           | j        j        j        }t          |
                    ||          g            d S )NrQ   r   rl   r/  r  r  r  r1  r  r7  rJ  )r   rU   r   r0  rI  r   r   rS   rh  r8   r
  rl   r  rd  r   implicitly_named_constraintsr+   rZ  )r}   r   r   rR   r0  rQ  r   expected_schemausers_fkeysfkey1
addr_fkeysr@  s               r?   r  z-ComponentReflectionTest.test_get_foreign_keys  s   
  	'FFF K-t{/Jyz""  9A 
	B//
6/JJKNE!3;;== 1 1E&M<0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 '(/:::&'444()I;777+,/?.@AAA **9>&*II
1:BBDD 	/ 	/E&M-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	E#$o666E"#UZ000E$%	{333E'(+;*<===+0D!!&!88"=====s$   B;;B?B?,FFFc                    |                      d|j        j        z  dt          j        j        z  dt          j        j        z            \  }}}t          |          }|                    |j                  }t          t          |          d           |d         }t          |d         t          j        j                   t          |d         |j                   t          |d         d	g           t          |d
         dg           |                    |j        t          j        j                  }t          t          |          d           |d         }	t          |	d         d |j        j        fv            t          |	d         |j                   t          |	d         d	g           t          |	d
         dg           d S )Nz%s.local_tablez%s.remote_tablez%s.remote_table_2r   r   r  r  r  rK   r  r]  rQ   r_  )r   rz   rl  r   r   rU   r   r
  rl   r   rD  r+   )
r}   r   r\  r^  r`  r   local_fkeysrl  remote_fkeysfkey2s
             r?   "test_get_inter_schema_foreign_keysz:ComponentReflectionTest.test_get_inter_schema_foreign_keys  s    59KKz1EE ::'."<<5
 5
1\> z""++K,<==Ca   AE#$gn&@AAAE"#^%8999E$%v...E'(;-888,,gn&@ - 
 
 	Cq!!!Q#$"6	
 	
 	
 	E"#[%5666E$%v...E'(:,77777rA   c                 |   |rt           j        }nd }t          |          }|                    d|          }|                     |          }|                     |||df         | j                   | j        j        j	        }|                     |                    ||          |||f         | j                   d S )Nr0  rQ   )
r   rU   r   r  r  rc  r  r   rZ  rl   )r}   r   r   rR   r   indexesr?  r@  s           r?   r  z(ComponentReflectionTest.test_get_indexes  s    
  	'FFF z""""76"::f--S&'*+T-F	
 	
 	
 +0VF33 !%	
 	
 	
 	
 	
rA   )rc  rf  )re  rg  ztname,ixnamec                    t          |          }|                    |          }|                                 d |f         }|                     ||| j                   t          |t                      |          }t          t          |j	                  d           t          t          |j	                  d         j        |           t          t          |j	                  d         j        |           d S )Nr   r   r   )r   r  r  rc  r  r   r   r   rD  rt  r   r  rR  rl   )r}   r   tnameixnamer   rt  expected_indexesr%  s           r?   test_get_noncol_indexz-ComponentReflectionTest.test_get_noncol_index8  s     z""""5))  ++--tUm<"2D4MNNN%:>>>C	NNADOOA$a(((DOOA#V,,,,,rA   c                     t          |          }|                                 }|                    |          }|                     d          d |f         }|                     ||| j                   d S )NT)r  )r   ri   r  r  rc  r  )r}   r   r   rl   	reflectedr?  s         r?   &test_get_temp_table_unique_constraintsz>ComponentReflectionTest.test_get_temp_table_unique_constraintsN  sr     z""##%%//55	lll%%tTl3C)BCCCCCrA   c                 2   t          |          }|                                 }|                    |          }|D ]}|                    dd            ddgddg}t          j        j        j        rg |d         d<   t          d |D             |           d S )	Nr  Fr   rv  )rE  r  rl   r   r  c                 *    g | ]}|d          dk    |S )rl   rv  rF   r  r   s     r?   r  zGComponentReflectionTest.test_get_temp_table_indexes.<locals>.<listcomp>d  s&    DDDSs6{m'C'CS'C'C'CrA   )	r   ri   r  r  r   rS   index_reflects_included_columnsr8   r   )r}   r   r   ru   rt  indexpecteds          r?   test_get_temp_table_indexesz3ComponentReflectionTest.test_get_temp_table_indexesW  s    z""))++
"":.. 	- 	-CGG%t,,,,ug}MM
 ;C 	0-/HQK)*DDGDDD	
 	
 	
 	
 	
rA   c                 2   |rt           j        }nd }t          ddgddg dddg dddd	d
gdddgdddgdgt          j        d                    }t          d|t          dt          j        d                    t          dt          j        d                    t          dt          j	                  t          d	t          j        d                    t          d
t          j        d                    |          }|D ]2}|
                    t          j        |d         d|d         i           3|                    |           t          |          }t          |                    d|          t          j        d                    }	t                      }
t!          t#          |          t#          |	                     t%          ||	          D ]f\  }}|                    dd           }|r|
                    |           t!          |                    dd           d            t!          ||           gt+                      }t          d|||          }	d |	j        D             }d |	j        D                                 dg          }|                    |          rJ |
r,t!          |
|           t!          |t                                 | j        j        j        }t!          |                    ||          g            d S )Nunique_ar   )rl   r  unique_a_b_c)r   br   unique_c_a_b)r   r   r  unique_asc_keyascr   zi.have.dotsr  zi have spacesr   rl   r   testtblrL  rD  rQ   r  r  r   )r   rR   c                     h | ]	}|j         
S rF   r   r  s     r?   	<setcomp>zFComponentReflectionTest.test_get_unique_constraints.<locals>.<setcomp>  s    ;;;#SX;;;rA   c                 P    h | ]#}t          |t          j                  |j        $S rF   )r   ro   r   rl   )r  uqs     r?   r  zFComponentReflectionTest.test_get_unique_constraints.<locals>.<setcomp>  s=     
 
 
"b122
G
 
 
rA   )r   rU   r)  operator
itemgetterr   r   ro   r   r   append_constraintr   r   r   r  r}  r   rD  rC  r  r  r   rt  constraints
differencerL  r   rZ  rl   )r}   r[   r   r   rR   uniquesrR  r  r   r{  names_that_duplicate_indexr  refldupereflected_metadata	idx_namesuq_namesr@  s                     r?   r  z3ComponentReflectionTest.test_get_unique_constraintsh  sX     	'FFF#cU;;'II'II)E5>JJ&>>(3%@@ #F++

 

 

 3	"&&3	"&&3
##5")B--((5")B--((

 

 

  	 	B###R%7IbjII    	Z   z""''	&'AA#F++
 
 
	
 &)UU"CLL#i..)))gy11 	 	JD$ 88.55D 5*..t444D))4000dOOOO%ZZ$	
 
 
	 <;):;;;	
 
+
 
 
 *n%
&
&	 	 ))(33333% 	!*I666#%%   +0D''v'>>CCCCCrA   c                     |rt           j        }nd }t          |          }dD ]5}|                    ||          }t	          t          |                     6d S )NrB  rQ   )r   rU   r   r   r+   bool)r}   r   r   rR   r   viewr  s          r?   r  z0ComponentReflectionTest.test_get_view_definition  sp    
  	'FFFz""D 	 	D((f(==ADGG	 	rA   c                 *   t          |          }t          t                    5  |                    d           d d d            n# 1 swxY w Y   t          t                    5  |                    d           d d d            d S # 1 swxY w Y   d S )Nview_does_not_existr0  )r   r   r"   r   r   s      r?   'test_get_view_definition_does_not_existz?ComponentReflectionTest.test_get_view_definition_does_not_exist  s   z""+,, 	< 	<$$%:;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<+,, 	. 	.$$W---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s#   AA
A
%BBBc                     t          |          }dD ]D\  }}|                    |          }d |D             |         }|                    dd          sJ EdS )a  test that 'autoincrement' is reflected according to sqla's policy.

        Don't mark this test as unsupported for any backend !

        (technically it fails with MySQL InnoDB since "id" comes before "id2")

        A backend is better off not returning "autoincrement" at all,
        instead of potentially returning "False" for an auto-incrementing
        primary key column.

        ))r0  r1  )rI  r@  )r>  r?  c                      i | ]}|d          |S r   rF   r  r   s     r?   r  zBComponentReflectionTest.test_autoincrement_col.<locals>.<dictcomp>  s    ...A1V9a...rA   r  TN)r   r  get)r}   r   r   rv  cnamer  id_s          r?   test_autoincrement_colz.ComponentReflectionTest.test_autoincrement_col  sz     z""
 	2 	2LE5
 ##E**D.....u5C77?D111111	2 	2rA   c                    t          t          j                  }|rt          j        nd }t          j        j        j        rt|                    d|          }t          t          |t                               |                    d|          }t          t          |t                               d S t          t                    5  |                    d|          }d d d            d S # 1 swxY w Y   d S )Nr0  rQ   rZ  )r   r   r=   rU   r   rS   r   r8   r   r+   r   r;   r   r   )r}   r   r   rR   r   s        r?   r   z.ComponentReflectionTest.test_get_table_options  s=    vy!!'1;##t19 	E(((@@CJsD))***(()9&(IICJsD))*****233 E E,,WV,DDE E E E E E E E E E E E E E E E E Es   C--C14C1c                    t          t          j                  t          j        j        j        r[|rt          j        nd                               }fd	                              D             }t          ||           d S t          t                    5                                  }d d d            d S # 1 swxY w Y   d S )NrQ   c                 D    i | ]}|f                     |           S )rQ   )r   )r  rR  r   rR   s     r?   r  zHComponentReflectionTest.test_multi_get_table_options.<locals>.<dictcomp>	  sB        !7!7f!7!M!M  rA   )r   r   r=   r   rS   r   r8   rU   get_multi_table_optionsr(  r   r   r   )r}   r   r   r?  r   rR   s       @@r?   test_multi_get_table_optionsz4ComponentReflectionTest.test_multi_get_table_options  s!   vy!!19 	5+5?V''4F..f.==C    !111@@  C SMMMMM233 5 522445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   !CC
Cc                     fd}|S )Nc                     t                    } ||d           ||d}| r
 |             } g }t          j        |v r|                    g d           t          j        |v r|                    ddg           t          j        |v r|                    ddg           | r| |d<   |r||d<    || |||                    d          	          }	|g}
|t          j        k    r>|	                                }|
                    d
           |
                    |           |t          j        k    r>|	                                }|
                    d           |
                    |           t                    |
|	fS )NrI  )r4   r   )rP  r0  does-not-existr  r  r  rR   r&  )rR   r4   r   r&  r4   r   )r   r    r"  r  r#  r$  r  r!   r  copyr  append)rR   r4   r   r  single_reflect_fn
exp_methodr   rt   r&  r?  kwsnkwr   s               r?   provide_fixturez>ComponentReflectionTest.get_multi_exp.<locals>.provide_fixture  s    :&&D d$5666 $//B "L4''##???   $&&##%8:J$KLLL+t33##^5E$FGGG &%8 2%1>"*VVN33	  C $C+++ggii   

3z'''ggii

3:&&S00rA   rF   )r}   r   r  s    ` r?   get_multi_expz%ComponentReflectionTest.get_multi_exp  s%    ,	1 ,	1 ,	1 ,	1 ,	1\ rA   c                      |||||t           j        | j                  \  }}}|D ]3}	|                                  |j        di |	}
t          |
|           4d S NrF   )r   r   r  r   r  r   r}   r  rR   r4   r   r  r   r  r?  rt   results              r?   #test_multi_get_table_options_tablesz;ComponentReflectionTest.test_multi_get_table_options_tablesD  s    
 ''
 
c3  	 	B1T177B77F	 	rA   c                      |||||t           j        | j                  \  }}}|D ]1}	|                                 t	           |j        di |	|           2d S r  )r   r  r  r   r   get_multi_table_comment)
r}   r  rR   r4   r   r  r   r  r?  rt   s
             r?   test_get_multi_table_commentz4ComponentReflectionTest.test_get_multi_table_commentV  s    
 ''
 
c3  	9 	9B,,22r22C8888	9 	9rA   c                     dt           fdt          |t                    r1t          fd|                                D             ||           d S t          fd|D             ||           d S )Nr  c                 R    t          j        dd|                                           S )Nz['\" ]r.  )resubr  )r  s    r?   _cleanz:ComponentReflectionTest._check_expressions.<locals>._cleanh  s"    6)R..44666rA   c                 .    i | ]\  }} |          |S rF   rF   )r  er  r  s      r?   r  z>ComponentReflectionTest._check_expressions.<locals>.<dictcomp>l  s'    999$!QA999rA   c                 &    g | ]} |          S rF   rF   )r  r  r  s     r?   r  z>ComponentReflectionTest._check_expressions.<locals>.<listcomp>n  s!    +++q+++rA   )r  r   r;   r   r  )r}   r  r?  err_msgr  s       @r?   _check_expressionsz*ComponentReflectionTest._check_expressionsg  s    	7 	7 	7 	7 	7 c4   	;9999&,,..9993HHHHH++++F+++S':::::rA   c                    |t          |||           d S t          t          |          t          |          |           t          ||          D ]\  }}t          |          t          |          z  D ]]}||v s||v rS||v rO| d| d| }|dv r$|                     ||         ||         |           @t          ||         ||         |           ^d S )Nz - )r  r  )r   rD  rC  r}  r  )	r}   r  r?  req_keysmsgrr  r   r  s	            r?   rc  z#ComponentReflectionTest._check_listp  s   S!!!!!FSXXs+++FC(( 5 51Q#a&& 5 5AH}}aAFF%("6"6Q"6"61"6"6 AAA 33AaD!A$HHHH!adG44455 5rA   c                    t          t          |                                          t          |                                                     |D ]2}||         ||         }}|r|g|g}}|                     ||||           3d S r   )r   r}  keysrc  )r}   r  r?  r  
make_listsr   r  r  s           r?   _check_table_dictz)ComponentReflectionTest._check_table_dict~  s    CCHHJJ000 	0 	0A!9c!fqA  sQC1Q8Q////		0 	0rA   c                      |||||t           j        | j                  \  }}}|D ]?}	|                                  |j        di |	}
|                     |
|| j                   @d S r  )r   r  r  r   get_multi_columnsr  r  r  s              r?   test_get_multi_columnsz.ComponentReflectionTest.test_get_multi_columns  s     '!
 
c3  	L 	LB+T+11b11F""630JKKKK	L 	LrA   c                      |||||t           j        | j                  \  }}}|D ]A}	|                                  |j        di |	}
|                     |
|| j        d           Bd S )NT)r  rF   )r   r  r  r   get_multi_pk_constraintr  r  r  s              r?   test_get_multi_pk_constraintz4ComponentReflectionTest.test_get_multi_pk_constraint  s    
 ''L
 
c3  	 	B1T177B77F""T3 #    	 	rA   c                     t           j        j        j        s`||fD ]]}|                                D ]D}t          |          dk    r/t          d |D                       r|                    |           E\d S d S )Nr   c              3   \   K   | ]'}|                     d           dt          j        fv V  (dS )rl   N)r  r,   r!  )r  r  s     r?   	<genexpr>z7ComponentReflectionTest._adjust_sort.<locals>.<genexpr>  sI       , ,>?f$)99, , , , , ,rA   r  )r   rS   ri  r8   r  rD  anysort)r}   r  r  r   objr  s         r?   _adjust_sortz$ComponentReflectionTest._adjust_sort  s    <D 	*) * *::<< * *C3xx!|| , ,CF, , , ) )| S)))	*	* 	** *rA   c                      |||||t           j        | j                  \  }}}|D ]W}	|                                  |j        di |	}
|                     |
|d            |                     |
|| j                   Xd S )Nc                 ,    t          | d                   S )Nr  tupleds    r?   r   zEComponentReflectionTest.test_get_multi_foreign_keys.<locals>.<lambda>  s    uQ/D-E'F'F rA   rF   )r   r
  r  r   get_multi_foreign_keysr  r  r  r  s              r?   test_get_multi_foreign_keysz3ComponentReflectionTest.test_get_multi_foreign_keys  s    
 '&L
 
c3  	H 	HB0T066266FFF   ""630FGGGG	H 	HrA   c                      |||||t           j        | j                  \  }}}|D ]?}	|                                  |j        di |	}
|                     |
|| j                   @d S r  )r   r  r  r   get_multi_indexesr  r  r  s              r?   test_get_multi_indexesz.ComponentReflectionTest.test_get_multi_indexes  s    
 '!
 
c3  	K 	KB+T+11b11F""630IJJJJ	K 	KrA   c                      |||||t           j        | j                  \  }}}|D ]W}	|                                  |j        di |	}
|                     |
|d            |                     |
|| j                   Xd S )Nc                 ,    t          | d                   S )Nr  r  r  s    r?   r   zKComponentReflectionTest.test_get_multi_unique_constraints.<locals>.<lambda>  s    U1^;L5M5M rA   rF   )r   r  r  r   get_multi_unique_constraintsr  r  r  r  s              r?   !test_get_multi_unique_constraintsz9ComponentReflectionTest.test_get_multi_unique_constraints  s    
 ',L
 
c3  	P 	PB6T6<<<<Ffc+M+MNNN""630NOOOO		P 	PrA   c                      |||||t           j        | j                  \  }}}|D ]W}	|                                  |j        di |	}
|                     |
|d            |                     |
|| j                   Xd S )Nc                 ,    t          | d                   S Nr  r  r  s    r?   r   zJComponentReflectionTest.test_get_multi_check_constraints.<locals>.<lambda>  s    U1Y<5H5H rA   rF   )r   r  r  r   get_multi_check_constraintsr  r  r  r  s              r?    test_get_multi_check_constraintsz8ComponentReflectionTest.test_get_multi_check_constraints  s    
 '+L
 
c3  	H 	HB5T5;;;;Ffc+H+HIII""630FGGGG		H 	HrA   r   r  r  r
  r  r  r  r  methodc                     t          |          }t          ||          }t          t                    5   |d           d d d            d S # 1 swxY w Y   d S )Ntable_does_not_exists)r   getattrr   r"   )r}   r  r   r   r   s        r?   test_not_existing_tablez/ComponentReflectionTest.test_not_existing_table	  s    0 z""tV$$+,, 	* 	*D()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   AAAc           	      |   t           j        fd}t          j                            t           d|          5  t          t          d          5  t          |                              t          dt                                d            d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                  d    |                     di           }t          d          |d<    | i |S )Nunreflectableerr)N
some_table)
setdefaultr#   )r   r   urmcs      r?   patchedz;ComponentReflectionTest.test_unreflectable.<locals>.patched"	  s;    or22B'>u'E'EB#$2q;A;;rA   r  r  r  )r   r  r,   patchobjectr	   r#   r   reflect_tabler   r   )r}   r   r  r  s      @r?   test_unreflectablez*ComponentReflectionTest.test_unreflectable	  s>   (	 	 	 	 	
 Zy*=wGG 	 	&'>FF  
##11,

33T                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s5   B1>BB1B	B1 B	!B11B58B5r   c                    t                      }|rt          j        nd |                    ||d           t	          |          }|                              }|rB||                              z  }	 ||                              z  }n# t          $ r Y nw xY wrfd|D             }t          t          |j                  t          |                     d S )NF)rR   r   resolve_fksc                     g | ]	} d | 
S )r-  rF   )r  r%  rR   s     r?   r  z9ComponentReflectionTest.test_metadata.<locals>.<listcomp>?	  s#    666!oo!oo666rA   )r   r   rU   reflectr   r(  r.  r/  r   r   r)  r   )r}   r   r   r   mr   r   rR   s          @r?   test_metadataz%ComponentReflectionTest.test_metadata-	  s    
 JJ'1;##t			*V5e	LLLz""%%f-- 	d))&111F$::6BBB&    	76666v666FF18fVnn-----s   8B 
BBc           
         t          d|t          dt          d          t          dt          d          d           |                    |           t	          |          }|                    d          }t          |ddi           |                    d          }d	 |D             }ddd
}t          ||           d S )Nunicode_commentsunicodeu   é試蛇ẟΩrS  emojiu	   ☁️✨u   試蛇ẟΩ✨r  c                 ,    i | ]}|d          |d         S r;  rF   r  s     r?   r  zAComponentReflectionTest.test_comments_unicode.<locals>.<dictcomp>S	  s"    777Q6AiL777rA   )r  r  r   r   r   r   r   r  r   r  )r}   r   r[   r   tcr  valuer?  s           r?   test_comments_unicodez-ComponentReflectionTest.test_comments_unicodeB	  s    9g???7G[999$	
 	
 	
 	
 	J'''z""##$677B)*+++ 23377$777)K@@E3rA   c           	      b   t          d|t          dt          d          d           |                    |           t	          |          }|                    d          }t          |ddi           |                    d          d         }t          |d         |d	         iddi           d S )
Nr  r  u&   🐍🧙🝝🧙‍♂️🧙‍♀️rS  u&   🎩🁰🝑🤷‍♀️🤷‍♂️r  r   rl   r   r  )r}   r   r[   r   r  r   s         r?   test_comments_unicode_fullz2ComponentReflectionTest.test_comments_unicode_fullW	  s    7G-UVVV<		
 	
 	
 	
 	J'''z""##$677BABCCC/003QvY)%1Y'Z[[[[[rA   r   r-   )NF)mrB   rC   rD   run_insertsrun_deletesr   rE   r\   r+  ri   rY   rW   r  r  r  r!   r!  r    r  r  r  propertyr  r  r  r  r  r  r  r  r  r  r  r   rS   schema_reflectionr  r  r  r  schema_create_deleter  r  r  r   r   rT   r,  r0  r  r4  rV   rr   r7  r  r;  r=  r9  r  rp  r[  r]  r   ra  !primary_key_constraint_reflectionr  r  rk  rr  r   r  rm  rn  ry  r  r|  temp_table_reflect_indexesr  r  r  r  table_reflectionr  r   r  fixturer  r   r'  r  r  r  rc  r  r  r  r  r  r  r  r  r  r  r  r   r  r  comment_reflection_full_unicoder  rF   rA   r?   r)  r)    s	        $$K+KN N [N
 k- k- [k-Z 
 
 [

 O O [OB   [4  ! ! !) ) )Z o^   B o^" " " "L o^^ ^ ^ ^@ 7 7 X7
 o^. . . .` / / X/
 o^V V V Vp 
 
 X
 o^s s s sj 2 2 X2
 o^C C C CJ ( ( X(
 o^8 8 8 8t # # X# 'G G ('G
 '8 8 ('8 'G G ('G '
8 
8 ('
8 '*; ; +* ('; '> > ('>
 'N N ('N W	(JK  
 W	w'(%,  !- !-  !-F W	w'(%,  - - - &D D '&D
 %%6 6 &% &%6
 (, , )(, (H H  )(H
 
 
 
0 W	g&./	ug&67$w'7'GG	

 (
 
 
<6 <6
 
<6B +	
 	
 ,+	
 ++ + ,++ +,%B B &% -, ,+B
 W4)12\   7
 
 87 
: W4)12\   7$> $> 87 $>L 0"8 "8  10"8H W4)12\   &
 
 '& 
, W3/  
 &*2- - 32 +* '& - +2D D 32 ,+D 0
 
 10
  W	w'((\   2TD TD 32 TDl %W4)12\     &% %. . &%. &2 2 '&20 W	w'((\  E E E W4!1!9:EBB5 5 CB5 _/ / _/b +   ,+  (9 9  )(9; ; ;5 5 5 50 0 0 0 L L L" 7   87$* * * 7H H  87H& &K K  '&K  2P P  32P" 1H H  21H" W	g.DE>	

 >	
 
(9:$9	

 $8	
 
g.AB+  .* */ .*   W$===W	w%&  . .  >=." (  )(( 5\ \ 65\ \ \rA   r)  c                       e Zd ZdZdZej        d             Zej        d             Zd Z	d Z
d Zej        j        d             Zej        j        d	             Zd
S )TableNoColumnsTest)reflect_tables_no_columnsTc                 P    t          d|           |                    |           d S Nr  )r   r   r}   r   r[   s      r?   table_no_columnsz#TableNoColumnsTest.table_no_columnsm	  s,    gx   J'''''rA   c                     t          d|           t          j        |dt          d                     t          j        |dt          d                     |                    |           d S )Nr  r^   z*CREATE VIEW empty_v AS SELECT * FROM emptyr_   zDROP VIEW IF EXISTS empty_v)r   r   ra   r$   r   r'  s      r?   view_no_columnsz"TableNoColumnsTest.view_no_columnsr	  sz    gx   <==	
 	
 	
 	mS)F%G%G	
 	
 	
 	J'''''rA   c                     t          dt                      |          }t          t          |j                  g            d S )Nr  r   r   r   r   r  r   )r}   r   r(  t2s       r?   test_reflect_table_no_columnsz0TableNoColumnsTest.test_reflect_table_no_columns	  s8    7HJJjAAADJJrA   c                     t          |          }t          |                    d          g            |                                }t          |dg i           d S )Nr  r&  )r   r   r  r  )r}   r   r(  r   multis        r?   !test_get_columns_table_no_columnsz4TableNoColumnsTest.test_get_columns_table_no_columns	  sY    z""DW%%r***&&((EOR()))))rA   c                     t                      }|                    |           t          |j                                      dg          sJ d S r&  )r   r
  r}  r   rL  )r}   r   r(  r  s       r?   "test_reflect_incl_table_no_columnsz5TableNoColumnsTest.test_reflect_incl_table_no_columns	  sG    JJ			*18}}))7)4444444rA   c                     t          dt                      |          }t          t          |j                  g            d S )Nempty_vr   r,  )r}   r   r*  r-  s       r?   test_reflect_view_no_columnsz/TableNoColumnsTest.test_reflect_view_no_columns	  s8    9hjj
CCCDJJrA   c                     t          |          }t          |                    d          g            |                    t          j                  }t          |dg i           d S )Nr5  )r   )Nr5  )r   r   r  r  r    r#  )r}   r   r*  r   r0  s        r?    test_get_columns_view_no_columnsz3TableNoColumnsTest.test_get_columns_view_no_columns	  sa    z""DY'',,,&&JO&<<E%r*+++++rA   N)rB   rC   rD   r   r   r   r   r(  r*  r.  r1  r3  rS   r   r6  r8  rF   rA   r?   r#  r#  i	  s        1LK_( ( _( _( ( _(  * * *5 5 5
    , , , , ,rA   r#  c                      e Zd ZdZ ej        ddg          d             Z ej                    d             Zd Zej	        j
        d             Zej	        j         ej        dd	d
d          d                         Zej	        j
         ej        ddd
d          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        d
dd
ej	        j        fd
d
dej	        j        fi d
dej	        j        fi dd
ej	        j        fd
d
dej	        j        fd
dd
ej	        j        fd          d             Z ej        e  e!j"        d          dfe ddfe# e!j$                    d fe  e!j"        d!          d"ej	        j%        fe  e!j"        d#          d$ej	        j%        fe& e'j(                    d%fe  e!j)        d&           e!j)        d'          z   d"ej	        j%        fd(          ej	        j*        d)                         Z+d
S )*ComponentReflectionTestExtraTF)paramsc                 ,    |j         rt          j        S d S r   )paramr   rU   )r}   requests     r?   use_schema_fixturez/ComponentReflectionTestExtra.use_schema_fixture	  s    = 	%%4rA   c                 >    t           j        fd            }|S )Nc              3   \   K   t                    fV                                 d S r   )r   r   )r   r   r[   r?  s    r?   goz:ComponentReflectionTestExtra.inspect_for_table.<locals>.go	  s:      $gj&9&99999
+++++rA   )
contextlibcontextmanager)r}   r[   r   r?  rB  s    ``` r?   inspect_for_tablez.ComponentReflectionTestExtra.inspect_for_table	  s=    		"	, 	, 	, 	, 	, 	, 
#	"	,
 	rA   c                     d t          fd|D             d           }t          |d           }t          ||           d S )Nc                     d                     t          j        d|                                 t          j                            S )N zand|\d|=|a|b|c|or|<|>)joinr  findallr  I)r  s    r?   	normalizez5ComponentReflectionTestExtra.ck_eq.<locals>.normalize	  s4    88
3W]]__bdKK  rA   c                 D    g | ]}|d           |d                   dS )rl   r  rl   r  rF   )r  itemrL  s     r?   r  z6ComponentReflectionTestExtra.ck_eq.<locals>.<listcomp>	  sC        f))DO2L2LMM  rA   c                     | d         S r  rF   rO  s    r?   r   z4ComponentReflectionTestExtra.ck_eq.<locals>.<lambda>	  
    d9o rA   r  c                     | d         S r  rF   rQ  s    r?   r   z4ComponentReflectionTestExtra.ck_eq.<locals>.<lambda>	  rR  rA   )r)  r   )r}   r{  r  rL  s      @r?   ck_eqz"ComponentReflectionTestExtra.ck_eq	  s    	 	 	
    %   /.
 
 
	 ..
 
 
 	Ix     rA   c                     |d          5 \  }}t          d|t          dt          j        d                    |           d d d            n# 1 swxY w Y   |                     |                    d|          g            d S )NrZ  rN   rL  rQ   )r   r   ro   r   rT  r  )r}   r[   rE  rR   r   s        r?   #test_check_constraint_no_constraintz@ComponentReflectionTestExtra.test_check_constraint_no_constraint	  s    /00 	4GVY vry}}--	   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	

++,<V+LL	
 	
 	
 	
 	
s   7AAA	my_inlineMyInlineNconstraint_namer   c                     |d          5 \  }}t          d|t          dt                      d          t          dt                      t          j        d|                    t          dt          d	                    |
           d d d            n# 1 swxY w Y   |                    d|
          }|                     ||pt          j	        ddg           d S )Nsa_ccrK   TrL   r   a > 1 AND a < 5r   rN   rO   rQ   a > 1 and a < 5rN  )
r   r   r   ro   r   r   r  rT  r,   r!  r}   r[   rE  rY  rR   r   r{  s          r?   test_check_constraint_inlinez9ComponentReflectionTestExtra.test_check_constraint_inline	  sC    w'' 	+>FItWYYD999II&)    vvbzz**   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  33GF3KK	

 ,7tx0 	
 	
 	
 	
 	
s   A?BBBmy_ck_const	MyCkConstc           
      P    |d          5 \  }}t          d|t          dt                                t          j        d|          |           d d d            n# 1 swxY w Y   |                    d|          }|                     ||pt          j        ddg           d S )Nr[  r   za = 1 OR (a > 2 AND a < 5)r   rQ   za = 1 or a > 2 and a < 5rN  )	r   r   r   ro   r   r  rT  r,   r!  r^  s          r?    test_check_constraint_standalonez=ComponentReflectionTestExtra.test_check_constraint_standalone	  s    w'' 		+>FIsGII&&"0      		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 33GF3KK	

 ,7tx9 	
 	
 	
 	
 	
s   AAA"%A"c                     |d          5 \  }}t          d|t          dt                      d          t          dt                      t          j        d                    t          dt                      t          j        dd	
                    t          dt                                t          dt          d                    t          j        dd
          t          j        dd
          t          j        dd
          |           d d d            n# 1 swxY w Y   |                    d|          }|                     |dddd	ddt          j
        ddg           d S )Nr[  rK   TrL   r   r\  r  zb > 1 AND b < 5rW  r   r   rN   rO   some_uqzc > 1 AND c < 5cc1	some_c_uqrQ   zc > 1 and c < 5rN  zb > 1 and b < 5r]  )r   r   r   ro   r   r   r   r  rT  r,   r!  )r}   r[   rE  rR   r   r{  s         r?   test_check_constraint_mixedz8ComponentReflectionTestExtra.test_check_constraint_mixed
  s   w'' 	+>FItWYYD999sGIIr'9:K'L'LMMII&'8{KKK 
 sGII&&vvbzz**#F;;;"#45AAA#Ck:::   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	& 33GF3KK	

+<==$1BCC.?@@	
 	
 	
 	
 	
s   DDD#&D#c                    t          d|t          dt          d                    t          dt          d                    t          dt          d                              }t          dt	          j        |j        j                  |j        j        t	          j        |j        j	                             dt          dt	          j
        |j        j                             t          d	|j        j                   |                               t                    }d	dgd
i dg}fd} ||d                     G d dt                    } G fddt                    }t          j        j        j        rdg d |d          d |d          gd
d}	 ||	           |                    d|	           dd g |d d          gd
d}
 ||
           |                    |
           t)          |                    d          |           t-                      }t          d|          }njt/          d          5  t)          |                    d          |           t-                      }t          d|          }d d d            n# 1 swxY w Y   |                     ||j        j                   d S )Nr%  xrD  yzt_idxa  long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string 
t_idx_longt_idx_2F)rl   r  rE  r  c                     t           j        j        j        rg | d<   j        j         dg i| d<   d S |                     di            d S )Nr  _includer  )r   rS   r  r8   r  rl   r  )entryr   s    r?   completeIndexzYComponentReflectionTestExtra.test_reflect_expression_based_indexes.<locals>.completeIndexV
  se    ?G 8+-'(!(-777,'(((   !2B77777rA   r   c                       e Zd Zd ZdS )[ComponentReflectionTestExtra.test_reflect_expression_based_indexes.<locals>.lower_index_strc                 B    |                                 }d|v od|v pd|v S )Nr  rj  rk  r  )r}   r   ols      r?   r  zbComponentReflectionTestExtra.test_reflect_expression_based_indexes.<locals>.lower_index_str.__eq__b
  s+    [[]]"}A#)*@sbyArA   Nr  rF   rA   r?   lower_index_strru  a
  s(        B B B B BrA   ry  c                       e Zd Z fdZdS )^ComponentReflectionTestExtra.test_reflect_expression_based_indexes.<locals>.coalesce_index_strc                 8    d|                                 v o|v S )Ncoalescerw  )r}   r   long_strs     r?   r  zeComponentReflectionTestExtra.test_reflect_expression_based_indexes.<locals>.coalesce_index_str.__eq__h
  s     !U[[]]2Hx57HHrA   Nr  )r~  s   r?   coalesce_index_strr{  g
  s5        I I I I I I IrA   r  )Nrl  Nzlower(x)zlower(y))rl   r  r  rE  zcoalesce(x, 'z')r   z>Skipped unsupported reflection of expression-based index t_idx)r   r   r   r%   r   r  r   rj  rl  rk  r}  r   r   r  r   rS    reflect_indexes_with_expressionsr8   insertr  r   r  r   r
   !compare_table_index_with_expectedr  rl   )r}   r[   r   r%  r   r  rs  ry  r  
expr_indexexpr_index_longr   r-  r~  s     `          @r?   %test_reflect_expression_based_indexeszBComponentReflectionTestExtra.test_reflect_expression_based_indexes:
  s   3r

##3r

##3r

##
 
 	gtz!#%((!#%ACE1B1BCCC'lDM!#%::;;;iJ'''z"" "!$#%	 
	8 	8 	8 	8 	8 	hqk"""	B 	B 	B 	B 	Bc 	B 	B 	B	I 	I 	I 	I 	I 	I 	I 	I 	I 	I
 <D #	> 1 1 1#OJ//#OJ// 
  	 	J M*%%%OOAz*** %!%&&'Cx'C'C'CDD    O M/***OOO,,,  %%x000BsBj999BB   > > D$$S))8444ZZ3*===> > > > > > > > > > > > > > > 	..*+0	
 	
 	
 	
 	
s   AJJ!$J!c                    t          d|t          dt          d                    t          dt          d                              }t          d|j        j                  }dg|j        |j        j                 d<   |	                    |           t          |          }|                    d          }t          |ddgdgdt          j        dg           t          |d	         d
         d|j        j        z           dg           t          dt                      |          }t          t!          |j                  d	         j        |j        j                 d         dg           d S )Nr%  rj  rD  rk  rm  includeF)rl   r  r  rE  r  r   r  z
%s_includer   )r   r   r   r%   r   rj  r  r  rl   r   r   r  r   r,   r!  r   r  rt  )r}   r[   r   r%  r   r   r  r-  s           r?   test_reflect_covering_indexz8ComponentReflectionTestExtra.test_reflect_covering_index
  s{   3r

##3r

##	
 
 GQSU##BEJ-23I>J'''z""&&s++ $%(E(+u#'+x 	
 	
 	
 	N,-z055 E		
 	
 	
 3

*===Q/
0A0FG E		
 	
 	
 	
 	
rA   c                     t          d|gd t          |          D             R  }|                    |           d t          |                              d          D             S )Nr%  c                 :    g | ]\  }}t          d |z  |          S )zt%dr   )r  rT  type_s      r?   r  zAComponentReflectionTestExtra._type_round_trip.<locals>.<listcomp>
  s*    HHH81efUQY&&HHHrA   c                     g | ]
}|d          S )r  rF   r  s     r?   r  zAComponentReflectionTestExtra._type_round_trip.<locals>.<listcomp>
  s    HHHa&	HHHrA   )r   rE  r   r   r  )r}   r   r[   r   r%  s        r?   _type_round_tripz-ComponentReflectionTestExtra._type_round_trip
  s{    
 IHy7G7GHHH
 
 

 	
HH7:#6#6#B#B3#G#GHHHHrA   c                     |                      ||t          j        dd                    D ]H}t          |t          j                  sJ t	          |j        d           t	          |j        d           Id S )N   r3  )r  rI  rM  r   r   	precisionscaler}   r   r[   typs       r?   test_numeric_reflectionz4ComponentReflectionTestExtra.test_numeric_reflection
  s    (()"3B":":
 
 	 	C c9#455555r"""	1	 	rA   c                     |                      ||t          j        d                    d         }t          |t          j                  sJ t	          |j        d           d S )N4   r   )r  rI  r   r   r   lengthr  s       r?   test_varchar_reflectionz4ComponentReflectionTestExtra.test_varchar_reflection
  sd    ##)"22"6"6
 

 #y/00000CJrA   c           
      "   t          d|t          dt          d          t          dt          d                    }|                    |           t	          d t          |                              d          D             ddd           d S )	Nr%  r   Tr4  r  Fc                 ,    i | ]}|d          |d         S )rl   r5  rF   r`  s     r?   r  zIComponentReflectionTestExtra.test_nullable_reflection.<locals>.<dictcomp>
  s2        FS_  rA   )r   r  )r   r   r   r   r   r   r  )r}   r   r[   r%  s       r?   test_nullable_reflectionz5ComponentReflectionTestExtra.test_nullable_reflection
  s    3$///3%000	
 
 	
 ":..::3??   U##	
 	
 	
 	
 	
rA   CASCADEzSET NULLz	NO ACTIONRESTRICTzexpected,ondelete,onupdatec                 T   i }|r||d<   |r||d<   ||}t          d|t          dt          d          d           t          d|t          dt          d          t          d	t          t          d
d                    t          dt	          d                    d           t          d|t          dt          d          t          dt	          d          d          t          dt                    t          j        dgdgfddi|d           |                    |           t          |          }|	                    d          d         d         t          fdD             i            |	                    d          d         d         t          |           d S )Nondeleteonupdaterj  rK   TrL   r   rR  x_idzx.idxidr   test
   userrl   rO   Fr4  tidztable.idmyfkr   r5   c                 2    i | ]}|         
||         S rF   rF   )r  r   optss     r?   r  zMComponentReflectionTestExtra.test_get_foreign_key_options.<locals>.<dictcomp>C  s(    111Aa1QQ111rA   )r   r   r   r   r   ro   r   r   r   r
  r   )	r}   r   r[   r  r  r  r5   r   r  s	           @r?   test_get_foreign_key_optionsz9ComponentReflectionTestExtra.test_get_foreign_key_options
  s   T  	+"*GJ 	+"*GJH4d333		
 	
 	
 	
 	4d33367JvE$B$B$BCC66"::&&	
 	
 	
 	
 	4d33366"::6665'""#* ,26=  
	
 
	
 
	
 
	
 	J'''z"" $$W--a0;11111112666$$V,,Q/	:D(rA   10z'?10'?z1|truez3 + 5z3\+5z(3 * 5)z3\*5zcurrent_timestamp|now|getdate35zdatatype, default, expected_regc           
      ^   t          d|t          dt          d          t          d||                    }|                    |           t	          |                              d          d         d         }t          j        d	d
|          }t          ||t          j	                   d S )Nr%  rK   TrL   thecol)server_defaultr   r  z	[\(\) \']r.  )flags)
r   r   r   r   r   r  r  r  r   
IGNORECASE)	r}   r[   r   datatyper  expected_regr%  r{  reflected_sanitizeds	            r?   test_server_defaultsz1ComponentReflectionTestExtra.test_server_defaultsI  s    : 4d3338Xg>>>	
 
 	
J''33C88;IF	 f\2yAA$l"-HHHHHHrA   ),rB   rC   rD   r   r   r   r?  rE  rT  rS   r  rV  "inline_check_constraint_reflectionr   r_  rc  rh  indexes_with_expressionsr  r  r  r  r  r  r  r  1foreign_key_constraint_option_reflection_ondelete1foreign_key_constraint_option_reflection_onupdate1fk_constraint_option_reflection_ondelete_noaction1fk_constraint_option_reflection_onupdate_restrict1fk_constraint_option_reflection_ondelete_restrictr  r   ro   r  r   trueexpression_server_defaultsr   r   nowliteral_columnserver_defaultsr  rF   rA   r?   r:  r:  	  s       KW_T5M***  +* W_  ! ! !. 1
 
 21
 8WZ0A  
 
  98
@ 1W{D3D  
 
  21
4 8
 
 98
> .X
 X
 /.X
t 5(
 (
 65(
TI I I &  '& &  '& &
 
 '&
  WN		
 N		
 N		
 N		
 N		
 N		
 .K& & &N3 3O& &N3l W	'"'$--+	$	"	'"'))Y'BGG7		
 BGI7		
 
848::?@Bc""%6R%6s%;%;;7		
 3/  2 %I I &%3 4I I IrA   r:  c                   8    e Zd ZdZdZed             Zd Zd ZdS )NormalizedNameTest)denormalized_namesTc                    t          t          dd          |t          dt          d                     t          t          dd          |t          dt          d          t          dt	          d                               d S )	Nr   Tr   rK   rL   r-  t1idzt1.id)r   r&   r   r   r   rZ   s     r?   r\   z NormalizedNameTest.define_tablesw  s    D)))4d333	
 	
 	

 	D)))4d3336:g..//		
 	
 	
 	
 	
rA   c                    t                      }t          t          dd          |t          j                  }|j        d         }|j        j                            |j        j	                  sJ t                      }|
                    t          j        d            |j        d         j        j                            |j        d         j        j	                  sJ d S )Nr-  Tr  r   r   c                 .    |                                  dv S )Nr   r-  rw  )rl   r  s     r?   r   zINormalizedNameTest.test_reflect_lowercase_forced_tables.<locals>.<lambda>  s    DJJLLL,H rA   )only)r   r   r&   r   r=   r   r   r  r   rK   r
  )r}   r   t2_reft1_refm3s        r?   $test_reflect_lowercase_forced_tablesz7NormalizedNameTest.test_reflect_lowercase_forced_tables  s    ZZD)))2VY
 
 
 4x}''44444ZZ


IHH 	 	
 	
 	
 y %0041B1EFFFFFFFrA   c                 p   d t          t          j                                                  D             }t	          |d                                         |d                                                    t	          |d                                         |d                                                    d S )Nc                 >    g | ]}|                                 d v |S )r  rw  )r  r%  s     r?   r  z;NormalizedNameTest.test_get_table_names.<locals>.<listcomp>  s5     
 
 
wwyyL(( (((rA   r   r   )r   r   r=   r(  r   upperr  )r}   
tablenamess     r?   r,  z'NormalizedNameTest.test_get_table_names  s    
 
VY''7799
 
 

 	JqM!!:a=#6#6#8#8999JqM!!:a=#6#6#8#899999rA   N)	rB   rC   rD   r   r   rE   r\   r  r,  rF   rA   r?   r  r  s  sX        *LK
 
 [
G G G: : : : :rA   r  c                   P    e Zd Zd Zd Zd Zd Zej        j	        d             Z
dS )ComputedReflectionTestc                 $   t          t          j                  }|                    d          }d |D             }t	          d|d         d         v            t          |d         d         d            t          |d         d         d            d S )Ncomputed_default_tablec                      i | ]}|d          |S r   rF   r  s     r?   r  zLComputedReflectionTest.test_computed_col_default_not_set.<locals>.<dictcomp>  s    ///QAfIq///rA   42with_defaultr  normalcomputed_col)r   r   r=   r  r+   r   )r}   r   r  col_datas       r?   !test_computed_col_default_not_setz8ComputedReflectionTest.test_computed_col_default_not_set  s    vy!! 899//$///0;;<<<HXy)4000H^$Y/66666rA   c                 X   t          t          j                  }|                    d          }d |D             }dD ]}t	          d||         v           |d         }t	          d|v            t	          d|d         v            t          |                     |d         d                   d           t          d|d         v t          j        j	        j
                   t          j        j	        j
        r2t          |d         d         t          j        j        j
                   d S d S )	Nr  c                      i | ]}|d          |S r   rF   r  s     r?   r  zKComputedReflectionTest.test_get_column_returns_computed.<locals>.<dictcomp>      +++&	1+++rA   )rK   r  r  computedr  r  	normal+42	persisted)r   r   r=   r  r+   r   rL  r   rS   "computed_columns_reflect_persistedr8   "computed_columns_default_persisted)r}   r   r  rN   r   compDatas         r?    test_get_column_returns_computedz7ComputedReflectionTest.test_get_column_returns_computed  s9   vy!! 899++d+++3 	1 	1CJd3i/0000'
h&'''	Xj11222DNN8J/	:;;[III8J//?G	
 	
 	
 >F 	$[1 CK    	 	rA   c                     t          d||         v            ||         d         }t          |                     |d                   |           t          j        j        j        r)t          d|v            t          |d         |           d S d S )Nr  r  r  )r+   r   rL  r   rS   r  r8   r   )r}   rN   columnr  r  r  s         r?   check_columnz#ComputedReflectionTest.check_column  s    
d6l*+++<
+DNN8I.//999>F 	2K8+,,,%y11111	2 	2rA   c                    t          t          j                  }|                    d          }d |D             }|                     |ddt
          j        j        j                   t
          j        j	        j        r|                     |ddd           t
          j        j
        j        r|                     |dd	d
           d S d S )Ncomputed_column_tablec                      i | ]}|d          |S r   rF   r  s     r?   r  zLComputedReflectionTest.test_get_column_returns_persisted.<locals>.<dictcomp>  r  rA   computed_no_flagr  computed_virtualznormal+2Fcomputed_storedz	normal-42T)r   r   r=   r  r  r   rS   r  r8   computed_columns_virtualcomputed_columns_storedr}   r   r  rN   s       r?   !test_get_column_returns_persistedz8ComputedReflectionTest.test_get_column_returns_persisted  s    vy!! 788++d+++?G		
 	
 	
 4< 	"	   3; 	!	    	 	rA   c                    t          t          j                  }|                    dt          j                  }d |D             }|                     |ddt          j        j        j	                   t          j        j
        j	        r|                     |ddd           t          j        j        j	        r|                     |d	d
d           d S d S )Nr  rQ   c                      i | ]}|d          |S r   rF   r  s     r?   r  zXComputedReflectionTest.test_get_column_returns_persisted_with_schema.<locals>.<dictcomp>  r  rA   r  z	normal/42r  znormal/2Fr  z	normal*42T)r   r   r=   r  rU   r  r   rS   r  r8   r  r  r  s       r?   -test_get_column_returns_persisted_with_schemazDComputedReflectionTest.test_get_column_returns_persisted_with_schema  s    vy!!#F,>   
 
 ,+d+++?G		
 	
 	
 4< 	"	   3; 	!	    	 	rA   N)rB   rC   rD   r  r  r  r  r   rS   rT   r  rF   rA   r?   r  r    sr        7 7 7  *2 2 2  6     rA   r  c                   j    e Zd ZdxZZdZdZed             Zd Z	d Z
ej        j        d             ZdS )IdentityReflectionTestNT)identity_columnsr  c                    t          d|t          dt                    t          dt          t                                           t          d|t          dt          t          dddd	d
dd                               t          j        j        j        rVt          d|t          dt                    t          dt          t          dd                    t          j	                   d S d S )Nr   r  id1r-  r   Tr   r   rW     alwaysstart	incrementminvaluemaxvaluecyclecacherL  )r  r  rQ   )
r   r   r   r   r   rS   rT   r8   r   rU   rZ   s     r?   r\   z$IdentityReflectionTest.define_tables  s   8W%%5'8::..		
 	
 	
 	   	
 	
 	
" #+ 	x))ugxt2'F'F'FGG)     	 	rA   c                 T   t           j        j        j        rd}t	          |          D ]}||vr|                    |           |rt          t          |          t          |                     |D ]i}|dk    r t          ||         ||         k               (|dv r t          ||         ||         k               Lt          ||         ||         |           jd S t          ||           d S t          |d         |d                    t          |d         |d                    d S )Nr  r  >   r  r  r  r  )	r   rS   identity_columns_standardr8   r  r  r   rD  r+   )r}   r  r?  approxcommon_keysr   s         r?   checkzIdentityReflectionTest.check'  sB   5= 	6K %[[ ! !K''IIaLLL 
 CJJC))) 1 1AJaCF 23333333aCF 23333E!Hc!fa00001 1 E3gG---k"C$455555rA   c                    t          t          j                  }|                    d          |                    d          z   }|D ]}|d         dk    rt	          d|v            !|d         dk    rsd|v rt          |d                    t          |d         d            t          d|v            |                     |d         t          d	d
d
d
dd	d
          d           |d         dk    rrd|v rt          |d                    t          |d         d            t          d|v            |                     |d         t          ddddddd          d	            d S )Nr   r-  rl   r  identityr  r  r  Fr   r  Tr  r   r   r   r  rW  r   )	r   r   r=   r  r*   r+   r   r  r;   r}   r   r  r   s       r?   test_reflect_identityz,IdentityReflectionTest.test_reflect_identityD  s   vy!!%%(8(8(>(>> &	 &	C6{h&&s*++++V%%"c))C0111C	ND)))
c)***


O$"#!"!+#          V%%"c))C0111C	ND)))
c)***


O#"#!#!#"   !    5&	 &	rA   c                    t          t          j                  }|                    dt          j                  }|D ]}|d         dk    rt          d|v             |d         dk    rrd|v rt          |d                    t          |d         d            t          d|v            |                     |d         t          d	d
ddddd          d	           d S )Nr   rQ   rl   r  r  r  r  r  TrL  r   r  Fr  r  )
r   r   r=   r  rU   r*   r+   r   r  r;   r  s       r?   test_reflect_identity_schemaz3IdentityReflectionTest.test_reflect_identity_schemap  s   vy!!V-?@@ 	 	C6{h&&s*++++V%%"c))C0111C	ND)))
c)***


O# "#!"!+#        	 	rA   )rB   rC   rD   r  r  r   r   rE   r\   r  r  r   rS   rT   r  rF   rA   r?   r  r    s         $$K+K;L  [B6 6 6:* * *X     rA   r  c                   |    e Zd ZdZed             Zej        j        d             Z	ej        j
        d             ZdS )CompositeKeyReflectionTestTc                 B   t          d|t          dt                    t          dt                    t          dt          j        d                    t          j        dddd          d d	          }t          d
|t          dt          d          t          dt                    t          dt                    t          dt          j        d                    t          j        g d|j        j	        |j        j
        |j        j        gd          d d		  	         d S )Ntb1rK   attrrl   rL  pk_tb1r   Tr=  tb2rL   pidpattrpnamer  r  r  fk_tb1_name_id_attr)r   r   r   rI  rq   ro   r   r   r   rl   rK   r  )r>   r[   r  s      r?   r\   z(CompositeKeyReflectionTest.define_tables  s   4!!67##69,R0011#FD&xHHH	
 	
 	
 	4d3335'""7G$$7I-b1122#)))SUXsuz2*  
 	
 	
 	
 	
 	
 	
rA   c                     t          |          }|                    | j        j        j                  }t          |                    d          g d           d S )Nr  rl   rK   r  )r   r  r   r  rl   r   r  )r}   r   r   rM   s       r?   test_pk_column_orderz/CompositeKeyReflectionTest.test_pk_column_order  sU     z"",,T[_-ABBKOO1224J4J4JKKKKKrA   c                 J   t          |          }|                    | j        j        j                  }t          t          |          d           |d         }t          |                    d          g d           t          |                    d          g d           d S )Nr   r   r  r#  r  r   )r   r
  r   r  rl   r   rD  r  )r}   r   r   foreign_keysrl  s        r?   test_fk_column_orderz/CompositeKeyReflectionTest.test_fk_column_order  s     z"",,T[_-ABBCq!!!QEII())+A+A+ABBBEII+,,.G.G.GHHHHHrA   N)rB   rC   rD   r   rE   r\   r   rS   r  r$  r   r'  rF   rA   r?   r  r    s~        K
 
 [
6 7L L 87L 7I I 87I I IrA   r  )r)  r:  r#  r   r   rH   r   r  r  r  r  )GrC  r  r  r9   ro   r.  r   r   r   r   r   r	   r
   r   r   	provisionr   r   rR   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rI  r  r   r    r!   excr"   r#   r$   r%   sql.elementsr&   
sql.schemar'   r(   r)   r*   r+   r,   r[   r0  
TablesTestr/   rH   r   TestBaser   r   r'  r)  r#  r:  r  ComputedReflectionFixtureTestr  r  r  __all__rF   rA   r?   <module>r0     s        				                                   $ $ $ $ $ $                   + + + + + + / / / / / /                                                                               " " " " " "                   ! ! ! ! ! ! # # # # # # * * * * * *             ' ' ' ' ' ' & & & & & & & & & & & & % % % % % %                   %    h1    S: S: S: S: S:* S: S: S:lJ
 J
 J
 J
 J
8& J
 J
 J
Z91 91 91 91 91x'8 91 91 91xT0 T0 T0 T0 T0X0 T0 T0 T0n1 1 1<H\ H\ H\ H\ H\n.E H\ H\ H\V:2, 2, 2, 2, 2,* 2, 2, 2,jRI RI RI RI RI?H4E RI RI RIj(: (: (: (: (:, (: (: (:V^ ^ ^ ^ ^XC ^ ^ ^BJ J J J JX0 J J JZ.I .I .I .I .I!4 .I .I .IbrA   