
    +h                        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\  Z$Z% G d d e	jL                        Z' G d! d"e'      Z( G d# d$e	jL                        Z) G d% d&e	jL                        Z* G d' d(e'      Z+ G d) d*e	jX                        Z- G d+ d,e	jX                        Z. G d- d.e	jL                        Z/ G d/ d0e	j`                        Z1 G d1 d2e	jL                        Z2 G d3 d4e	jL                        Z3d5Z4y)6    N   )config)engines)eq_)expect_warnings)fixtures)is_)get_temp_table_name)temp_table_keyword_args)Column)Table   )event)
ForeignKey)func)Identity)inspect)Integer)MetaData)String)testing)types)DDL)Index)quoted_name)BLANK_SCHEMA)is_false)is_true)NNc                       e Zd Zed        Zy)OneConnectionTablesTestc                     t         j                  j                  j                  r1ddlm} t        j                  t        |j                  d            S t         j                  S )Nr   )poolclass)	poolclassscope)options)r   requirementsindependent_connectionsenabled
sqlalchemyr"   r   testing_enginedict
StaticPooldb)clsr"   s     [/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/testing/suite/test_reflection.py
setup_bindz"OneConnectionTablesTest.setup_bind%   sI    
 66>>'))tgF  99    N)__name__
__module____qualname__classmethodr1    r2   r0   r    r    $   s     r2   r    c                   \   e Zd ZdZed        Zed        Zed        Zed        Zd Z	e
j                  j                  d        Z e
j                  dd	      e
j                  j                  d
               Ze
j                  j"                  d        Ze
j                  j"                  e
j                  j&                  e
j                  j(                  d                      Z e
j                  dd      e
j                  j                  e
j                  j                  d                      Zy)HasTableTestTc                    t        d|t        dt        d      t        dt        d                   t        j
                  j                  j                  rAt        d|t        dt        d      t        dt        d            t        j                         t        j
                  j                  r| j                  |       t        j
                  j                  j                  r| j                  |       y y )	N
test_tableidTprimary_keydata2   test_table_sschema)r   r   r   r   r   requiresschemasr)   r   test_schemaview_reflectiondefine_viewshas_temp_tabledefine_temp_tablesr/   metadatas     r0   define_tableszHasTableTest.define_tables7   s    4d366":&		
 ##++tW$7vvbz*)) ++X&**22""8, 3r2   c                    d}t        j                  |dt        |             t        j                  |dt        d             t        j                  j
                  j                  rwdt        j                  dt        j                  d}t        j                  |dt        |             t        j                  |dt        dt        j                  z               y y )	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   rD   rE   r)   r   rF   )r/   rL   querys      r0   rH   zHasTableTest.define_viewsM   s    CX~s5z:X}c..AB##++ &&&&  LL>3u:>LL%););<= ,r2   c                 b    t        t        t        j                  dt        j                        S )N	user_tmp_)r
   r   r.   ident)r/   s    r0   temp_table_namezHasTableTest.temp_table_namec   s!    "FII>
 	
r2   c                 "   t        t        t        j                        }| j                         }t	        ||t        dt        j                  d      t        dt        j                  d            fi |}t        j                  j                  j                  rwt        j                  j                  j                  rRt        j                  |dt!        dt        j"                  z               t        j                  |dt!        d	             y y y )
Nr<   Tr=   namer@   rO   =create temporary view user_tmp_v as select * from user_tmp_%srP   drop view user_tmp_v)r   r   r.   rW   r   r   saINTVARCHARr   rD   rG   r)   temporary_viewsr   rR   r   rV   r/   rL   kw
table_nameuser_tmps        r0   rJ   zHasTableTest.define_temp_tablesi   s    $VVYY7((*
4T262::b>*	

 
 ,,44  0088LL028,,? LL=#6L2MN 9 5r2   c                    t         j                  j                         5 }t        t         j                  j                  j                  |d             t        t         j                  j                  j                  |d             t        t         j                  j                  j                  |d             d d d        y # 1 sw Y   y xY w)Nr;   rA   nonexistent_table)r   r.   beginr   dialect	has_tabler   selfconns     r0   test_has_tablezHasTableTest.test_has_table   s    YY__ 	M$FII%%//lCDVYY&&00~FGVYY&&007JKL	M 	M 	Ms   BCCc                    t         j                  j                         5 }t        t         j                  j                  j                  |dt         j                               t        t         j                  j                  j                  |dt         j                               t        t         j                  j                  j                  |dt         j                               d d d        y # 1 sw Y   y xY w)Nr;   rB   rA   re   )r   r.   rf   r   rg   rh   rF   r   ri   s     r0   test_has_table_schemaz"HasTableTest.test_has_table_schema   s    YY__ 	$		!!++,v/A/A , 
 		!!++.1C1C , 
 		!!++-f6H6H , 	 	 	s   C
C22C;oraclezJper #8700 this remains at its previous behavior of not working within 1.4.c                 N    t        |      }t        |j                  d             y Nvvr   r   rh   rj   
connectioninsps      r0   test_has_table_viewz HasTableTest.test_has_table_view   s     z"t$%r2   c                 n    t        |      }| j                         }t        |j                  |             y N)r   rW   r   rh   )rj   ru   rv   rW   s       r0   test_has_table_temp_tablez&HasTableTest.test_has_table_temp_table   s+    z"..0/0r2   c                 N    t        |      }t        |j                  d             y N
user_tmp_vrs   rt   s      r0   test_has_table_temp_viewz%HasTableTest.test_has_table_temp_view   s     z"|,-r2   zIper #8700 this remains at its previous behavior of not working within 1.4c                 l    t        |      }t        |j                  dt        j                               y rq   )r   r   rh   r   rF   rt   s      r0   test_has_table_view_schemaz'HasTableTest.test_has_table_view_schema   s'     z"tV%7%789r2   N)r3   r4   r5   __backend__r6   rM   rH   rW   rJ   rl   r   rD   rE   rn   fails_onviewsrw   rI   rz   rG   r_   r~   r   r7   r2   r0   r9   r9   4   sw   K- -*  * 
 

 O O0M  $ W	
 & & $$1 %1
 $$%%%%. & & %. W	
 :  :r2   r9   c                   ^    e Zd ZdZed        Zd Zej                  j                  d        Z
y)HasIndexTestTc                    t        d|t        dt        d      t        dt        d                  }t	        d|j
                  j                         t        j                  j                  j                  rbt        d|t        dt        d      t        dt        d            t        j                        }t	        d	|j
                  j                         y y )
Nr;   r<   Tr=   r?   r@   my_idxrB   my_idx_s)r   r   r   r   r   cr?   r   rD   rE   r)   r   rF   )r/   rL   tts      r0   rM   zHasIndexTest.define_tables   s    4d366":&	
 	h		"##++tW$7vvbz*))B *bddii( ,r2   c                    t         j                  j                         5 }t         j                  j                  j	                  |dd      sJ t         j                  j                  j	                  |dd      rJ t         j                  j                  j	                  |dd      rJ t         j                  j                  j	                  |dd      rJ 	 d d d        y # 1 sw Y   y xY w)Nr;   r   r   re   nonexistent_idx)r   r.   rf   rg   	has_indexri   s     r0   test_has_indexzHasIndexTest.test_has_index   s    YY__ 
	$99$$..t\8LLLyy((22lJ   yy((22)8   yy((22l$5   
	 
	 
	s   B5CC'c                 T   t         j                  j                         5 }t         j                  j                  j	                  |ddt         j
                        sJ t         j                  j                  j	                  |ddt         j
                        rJ t         j                  j                  j	                  |ddt         j
                        rJ t         j                  j                  j	                  |ddt         j
                        rJ 	 d d d        y # 1 sw Y   y xY w)Nr;   r   rB   r   re   nonexistent_idx_s)r   r.   rf   rg   r   rF   ri   s     r0   test_has_index_schemaz"HasIndexTest.test_has_index_schema   s   YY__ 	$99$$..lJv7I7I /    yy((22lHV5G5G 3    yy((22#))	 3    yy((22#))	 3    	 	 	s   C5DD'N)r3   r4   r5   r   r6   rM   r   r   rD   rE   r   r7   r2   r0   r   r      s>    K) )&  r2   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d	        Zed
        Zee	j                  j"                  d               Zee	j                  j&                  d               Zee	j                  j*                  d               Zy)QuotedNameArgumentTestonceTc                 6   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                  rt        j                  j                  j                  rddg}ndg}|D ]  }dt        j                   j"                  j$                  j'                  d|z        dt        j                   j"                  j$                  j'                  |      }t)        j*                  |dt-        |             t)        j*                  |d t-        d!t        j                   j"                  j$                  j'                  d|z        z                y y )"Nquote ' oner<   rY   r@   r?   
related_idzpk quote ' onerY   zix quote ' onezuq quote' onez
related.idzfk quote ' onezname != 'foo'zck quote ' onezquote ' one commentT)commenttest_needs_fkquote " twozpk quote " twozix quote " twozuq quote" twozfk quote " twozck quote " two zquote " two commentrelatedr=   r   rQ   view %s AS SELECT * FROM rO   rP   DROP VIEW %s)r   r   r   r   r\   PrimaryKeyConstraintr   UniqueConstraintForeignKeyConstraintCheckConstraintr   rD   symbol_names_w_double_quoter)   view_column_reflectionr   r.   rg   identifier_preparerquoter   rR   r   )r/   rL   namesrY   rS   s        r0   rM   z$QuotedNameArgumentTest.define_tables   s   4!66":&66":&<)##D/?@HH%v.$ ##-= 5EF.%	
* 77??tW%vvbz*vvbz*|W-''3CD)62##( ''F\N1A ""?9JK2"%* 	4d39g&	
 22::;;CC!! "  II%%99??!D( II%%99??E	 X~s5zB!& ))++??EE%,	 ;r2   c                 n     t        j                  ddt         j                  j                  f      |       S )N)r   r   )r   combinationsrD   r   )fns    r0   quote_fixturesz%QuotedNameArgumentTest.quote_fixturesQ  s:    
w##G,,HHI
  	r2   c                 X    t        t        j                        }|j                  |       y ry   )r   r   r.   get_table_optionsrj   rY   rv   s      r0   test_get_table_optionsz-QuotedNameArgumentTest.test_get_table_optionsW  s    vyy!t$r2   c                 b    t        t        j                        }|j                  d|z        sJ y )Nr   )r   r   r.   get_view_definitionr   s      r0   test_get_view_definitionz/QuotedNameArgumentTest.test_get_view_definition]  s+     vyy!''	D(8999r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_columnsr   s      r0   test_get_columnsz'QuotedNameArgumentTest.test_get_columnsc  $    vyy!%%%r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_pk_constraintr   s      r0   test_get_pk_constraintz-QuotedNameArgumentTest.test_get_pk_constrainth  s$    vyy!%%d+++r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_foreign_keysr   s      r0   test_get_foreign_keysz,QuotedNameArgumentTest.test_get_foreign_keysm  s$    vyy!$$T***r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_indexesr   s      r0   test_get_indexesz'QuotedNameArgumentTest.test_get_indexesr  r   r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_unique_constraintsr   s      r0   test_get_unique_constraintsz2QuotedNameArgumentTest.test_get_unique_constraintsw  s&     vyy!**4000r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_table_commentr   s      r0   test_get_table_commentz-QuotedNameArgumentTest.test_get_table_comment}  s&     vyy!%%d+++r2   c                 \    t        t        j                        }|j                  |      sJ y ry   )r   r   r.   get_check_constraintsr   s      r0   test_get_check_constraintsz1QuotedNameArgumentTest.test_get_check_constraints  s&     vyy!))$///r2   N)r3   r4   r5   run_create_tablesr   r6   rM   r   r   r   rD   r   r   r   r   r   r   unique_constraint_reflectionr   comment_reflectionr   check_constraint_reflectionr   r7   r2   r0   r   r      s+   KQ Qf % %
 ,,: - : & & , , + + & & 221 3 1 ((, ) , 110 2 0r2   r   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ej                  j                  d        Zej                  j                  d	        Zej                  j                  d
        Zej                  j                  d        Zej                  j&                   ej(                  dddddej                  j*                  fddddddej                  j*                  fdddddej                  j*                  fd      d               Zej                  j.                  d        Zej                  j2                  ej                  j.                  ej                  j4                  d                      Zej                  j8                  d        Zej                  j8                  ej                  j*                  d               Zd4dZ ej(                  dddej                  j*                  fddej                  j2                  fddej                  j*                  ej                  j2                  z   fd      d        Z ej                  jB                  d        Z"ej                  jB                  ej                  jF                  ej                  j4                  d                      Z$ ej(                  ddej                  j*                  fd      ej                  jJ                  d                Z& ej(                  ddej                  j*                  fd      ej                  j&                  d!               Z'ej                  jP                  ej                  j*                  d"               Z)d# Z* ej(                  ddej                  j*                  fd      d$        Z+ ej(                  d%d&d'      ej                  jX                  ej                  jZ                  d(                      Z.ej                  jB                  ej                  j^                  d)               Z0ej                  jb                  d*        Z2 ej(                  dej                  j*                  fdd      ej                  j^                  d+               Z3ej                  j2                   ej(                  ddej                  j*                  fd      d,               Z4 ej(                  d-d.dej                  j*                  fd/       ejj                  d0d1      d2               Z6ej                  jn                  d3        Z8y)5ComponentReflectionTestNTc                     | j                  |d        t        j                  j                  j                  r+| j                  |t        j
                  j                         y y ry   )define_reflected_tablesr   rD   rE   r)   r   rF   rK   s     r0   rM   z%ComponentReflectionTest.define_tables  sF    ##Hd3##++'''..2L2LM ,r2   c                    |r|dz   }nd}t         j                  j                  j                  rt	        d|t        dt        j                  d      t        dt        j                  d      d	
      t        dt        j                  d      d	
      t        dt        j                  t        j                  d|z  d            |d      }njt	        d|t        dt        j                  d      t        dt        j                  d      d	
      t        dt        j                  d      d	
      |d      }t	        d|t        dt        j                  d      t        dt        j                  t        j                  d|z              t        dt        j                  d            |d       t	        d|t        dt        j                        t        dt        j                  t        j                  |j                  j                              t        dt        j                  d            t        j                  dd      |d       t	        d|t        dt        j                  dd      t        dt        j                  d      d !      t        d"t        j                  d      d#!      |d$%       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        d,t"        j&                  j(                  j*                  z              t        dt        j                  d            |d       t	        d-|t        dt        j                  d      t        dt        j                  d            |d       t         j                  j,                  j                  r| j/                  ||       |st	        d.|t        d/t        j                  d            d0      }t	        d1|t        dt        j                  d      t        d/t        j                  d            d0      }t         j                  j0                  j                  r\t3        d2|j                  j4                  j7                                t3        d3|j                  j4                  j7                                t         j                  j8                  j                  r| j;                  ||       |s7t         j                  j<                  j                  r| j?                  |       y y y )4N. usersuser_idTr=   test1   Fnullabletest2parent_user_idz%susers.user_id
user_id_fkr   rC   r   
dingalingsdingaling_id
address_idz%semail_addresses.address_idr?      email_addressesremote_user_idemail_address   email_ad_pkcomment_testr<   
id comment)r>   r   data % comment)r   d2)Comment types type speedily ' " \ '' Fun!the test % ' " \ table comment)rC   r   local_table	remote_idz%s.remote_table_2.id)r   rC   remote_tablelocal_idz%s.local_table.idremote_table_2noncol_idx_test_nopkqr   noncol_idx_test_pknoncol_idx_nopknoncol_idx_pk) r   rD   self_referential_foreign_keysr)   r   r   r\   r]   CHARFloatr   r   r   r   r   r   cross_schema_fk_reflectionr   rF   r.   rg   default_schema_nameindex_reflectiondefine_indexindexes_with_ascdescr   r   descr   rH   temp_table_reflectionrJ   )r/   rL   rC   schema_prefixr   r   r   s          r0   r   z/ComponentReflectionTest.define_reflected_tables  sn   "SLMM99AAy"&&d;w
U;we<$JJMM)M9 "E" y"&&d;w
U;we<"E 	>2::4@

<}LM
 6299R=)	
 	<, "**bmmEGGOO.L ?BIIbM2##L}E	
 	4|L6299R=2BC		"H
 9	
 66>>~!4>6299R=1#"2W^^5O5OO #'!99,,@@ "4>""/$ii//CCD 6299R=1!"& $4>6299R=1!"& ,,44Xu-',*3		!-"&	($ &+(4>3		!-"&&" ##88@@+-A-C-C-E-E-J-J-LM/+=+?+?+A+A+F+F+HI22::Xv.'**@@HH""8, Ivr2   c                    t        t        t        j                        }t        t        t        j                  dt        j                  z        }t        ||t        dt        j                  d      t        dt        j                  d            t        dt        j                        t        j                  ddt        j                  z  	      t        j                  d
d      fi |}t        j                  j                  j                  rwt        j                  j                   j                  rRt#        j$                  |dt'        dt        j                  z               t#        j$                  |dt'        d             y y y )Nuser_tmp_%sr<   Tr=   rY   r@   foouser_tmp_uq_%sr   user_tmp_ixrO   rZ   rP   r[   )r   r   r.   r
   rV   r   r   r\   r]   r^   r   r   r   rD   rG   r)   r_   r   rR   r   r`   s        r0   rJ   z*ComponentReflectionTest.define_temp_tables%  s   $VVYY7(FII}v||;

 4T262::b>*5"&&! -=-LMHH]E*
 
" ,,44  0088LL028,,? LL=#6L2MN 9 5r2   c                    t        d|j                  j                  |j                  j                         t        d|j                  j                  |j                  j                  |j                  j                         y )Nusers_t_idxusers_all_idx)r   r   r   r   r   )r/   rL   r   s      r0   r   z$ComponentReflectionTest.define_indexI  sD    mUWW]]EGGMM:ouwwuww}}Mr2   c           	          dD ]]  }|}|r|d|}|dz   }d|d|}t        j                  |dt        |             t        j                  |dt        d|z               _ y )	N)r   r   r   _vrQ   r   rO   rP   r   )r   rR   r   )r/   rL   rC   rb   fullname	view_namerS   s          r0   rH   z$ComponentReflectionTest.define_viewsN  sl    6 	J!H&,j9 4IE
 LL>3u:>LL-^i-G)H	r2   c                     t        | j                        }| j                  t        j                  j
                  |j                         v        y ry   )r   bindassert_r   r   rF   get_schema_namesrj   rv   s     r0   test_get_schema_namesz-ComponentReflectionTest.test_get_schema_names_  s4    tyy!W^^//43H3H3JJKr2   c                     |j                  ddt        t        j                  j                  i      }t        |      }| j                  t        j                  j                  |j                         v        y)z
test #7300r  bar)schema_translate_mapN)execution_optionsr   r   r   rF   r   r  r  rt   s      r0   %test_get_schema_names_w_translate_mapz=ComponentReflectionTest.test_get_schema_names_w_translate_mape  sb      11ugnn88" 2 

 z"W^^//43H3H3JJKr2   c                 r    t        j                         }t        |       t        |j                  d      sJ y )Nr   )r   r+   r   hasattrrg   )rj   engines     r0   test_dialect_initializez/ComponentReflectionTest.test_dialect_initializes  s,    '')v~~'<===r2   c                     t        | j                        }t        |j                  | j                  j                  j                         y ry   )r   r  r   r   rg   r  s     r0   test_get_default_schema_namez4ComponentReflectionTest.test_get_default_schema_namey  s0    tyy!D$$dii&7&7&K&KLr2   )NTFFF)foreign_keyTFF)NFTF)NTTFz/order_by,include_plain,include_views,use_schemaargnamesc                    |rt         j                  }nd }g d}t        |      }|r:|j                  |      }	|	j	                          ddg}
t        t        |	      |
       |r~|r'|j                  |      D cg c]  }|d   r|d    }}n|j                  |      }|D cg c]	  }||vs| }	}|dk(  rg d}
t        |	|
       y g d}
t        t        |	      |
       y y c c}w c c}w )N)r   r   r   r   r   r   email_addresses_vusers_vr   r!  )r   r   r   )r   r   r   )	r   rF   r   get_view_namessortr   sortedget_sorted_table_and_fkc_namesget_table_names)rj   ru   order_byinclude_plaininclude_views
use_schemarC   _ignore_tablesrv   table_namesanswerrectablests                 r0   test_get_table_namesz,ComponentReflectionTest.test_get_table_names~  s    ''FF
 z"--f5K)95F{#V,  $BB6J1v F  --f5&,H0G1HKH=(CK(CF;'0!  Is   8C"!	C'+C'c                     t        | j                        }|j                         }t        t	        |      dt
        j                  z  g       y )Nr  )r   r  get_temp_table_namesr   r)  r   rV   rj   rv   temp_table_namess      r0   test_get_temp_table_namesz1ComponentReflectionTest.test_get_temp_table_names  s;    tyy!446F#$}v||'C&DEr2   c                 z    t        | j                        }|j                         }t        t	        |      dg       y r|   )r   r  get_temp_view_namesr   r)  r9  s      r0   test_get_temp_view_namesz0ComponentReflectionTest.test_get_temp_view_names  s3     tyy!335F#$|n5r2   c                 $    | j                          y ry   )_test_get_commentsrj   s    r0   test_get_commentsz)ComponentReflectionTest.test_get_comments  s    !r2   c                 V    | j                  t        j                  j                         y ry   )r@  r   r   rF   rA  s    r0   test_get_comments_with_schemaz5ComponentReflectionTest.test_get_comments_with_schema  s     	 : :;r2   c                 4   t        | j                        }t        |j                  d|      ddi       t        |j                  d|      dd i       t        |j	                  d|      D cg c]  }|d   |d   d c}d	d
dddddddg       y c c}w )Nr   rB   textr   r   rY   r   )rY   r   r   r<   )r   rY   r   r?   r   r   )r   r  r   r   r   )rj   rC   rv   r3  s       r0   r@  z*ComponentReflectionTest._test_get_comments  s    tyy!"">&"A:;	

 	D""76":VTNK  ++N6+J VY@
 )$7,f= I 			
s   .B)FFzuse_views,use_schemac                    |rt         j                  }nd }| j                  j                  | j                  j                  }}|rddg}nddg}t        |      }t        |||f      D ]  \  }	}
|}|j                  |	|      }| j                  t        |      dkD  t        |             t        |
j                        D ]  \  }}t        |j                  ||   d          ||   d   j                  }|j                  }t!        |t"        j$                  j&                        r|j                  }t)        j*                  d	      r2|t,        j.                  t,        j0                  fv rt,        j.                  }| j                  t        t3        |j4                        j7                  |j4                        j7                  t,        j8                  t,        j:                  t,        j0                  t,        j.                  t,        j<                  t,        j>                  t,        j@                  g            dkD  |j                  d
|j                  d||   d   d
|d       |jB                  r||   d   J   y )Nr&  r%  r   r   rB   r   rY   typero   (z), )default)"r   rF   r4  r   r   r   zipr   r  len	enumeratecolumnsr   rY   	__class__rH  
isinstancer\   r   
TypeEnginer   against	sql_typesDateDateTimeset__mro__intersectionr   NumericTimer   _Binaryr>   )rj   ru   	use_viewsr/  rC   r   	addressesr1  rv   rb   tableschema_namecolsicolctype	ctype_defs                    r0   r   z(ComponentReflectionTest.test_get_columns  s    ''FF KK--t{{/J/Jy$&9:K"$56Kz"!$[5)2D!E /	6J K##J{#CDLLTQD	2 $EMM2 (63CHHd1gfo.Q11HH	i)<)<= ) 3 3I ??8,NN&&? 2 !*I
 EMM*%i&7&78% ) 1 1 ) 1 1 ) 2 2 ) ) ) 0 0 ) 1 1
 " xx476?EC#* 79-555Q(6/	6r2   c                    t        t        | j                  dt        j                  z        }| j                  |   }t        | j                        }|j                  |      }| j                  t        |      dkD  t        |             t        |j                        D ]!  \  }}t        |j                  ||   d          # y )Nr  r   rY   )r
   r   r  rV   r4  r   r   r  rM  rN  rO  r   rY   )rj   rb   rc   rv   ra  rb  rc  s          r0   test_get_temp_table_columnsz3ComponentReflectionTest.test_get_temp_table_columns1  s    (DII}v||;

 ;;z*tyy!
+SY]CI. 0 01 	+FAs$q'&/*	+r2   c                     t        | j                        }|j                  d      }t        |D cg c]  }|d   	 c}g d       y c c}w )Nr}   rY   )r<   rY   r  )r   r  r   r   rj   rv   ra  rc  s       r0   test_get_temp_view_columnsz2ComponentReflectionTest.test_get_temp_view_columns>  s?     tyy!-D)SS[)+@A)s   AFr/  c                    |rt         j                  j                  }nd }| j                  j                  | j                  j
                  }}t        |      }|j                  |j                  |      }|d   }t        |dg       |j                  |j                  |      }	|	d   }
t        |
dg       t         j                  j                  j                         5  t        |	d   d       d d d        y # 1 sw Y   y xY w)NrB   constrained_columnsr   r   rY   r   )r   r   rF   r4  r   r   r   r   rY   r   rD   reflects_pk_namesfail_if)rj   ru   r/  rC   r   r^  rv   
users_consusers_pkeys	addr_cons
addr_pkeyss              r0   r   z.ComponentReflectionTest.test_get_pk_constraintF  s    
 ^^//FF;;,,dkk.I.Iyz"++EJJv+F
 !67K)%**9>>&*I	45
J'//779 	2	&!=1	2 	2 	2s   C66C?c                    |rt         j                  }nd }| j                  j                  | j                  j                  }}t        |      }|}t        j                  j                  j                  r|j                  |j                  |      }|d   }	t        j                  j                  j                         5  t        |	d   d       d d d        t        |	d   |       t        |	d   |j                         t        |	d   dg       t        j                  j                  j                  rt        |	d	   d
g       |j                  |j                  |      }
|
d   }	t        j                  j                  j                         5  | j!                  |	d   d u       d d d        t        |	d   |       t        |	d   |j                         t        |	d   dg       t        |	d	   dg       y # 1 sw Y   (xY w# 1 sw Y   _xY w)NrB   r   rY   r   referred_schemareferred_tablereferred_columnsr   rm  r   r   )r   rF   r4  r   r   r   r   rD   r   r)   r   rY   named_constraintsro  r   implicitly_named_constraintsr  )rj   ru   r/  rC   r   r^  rv   expected_schemausers_fkeysfkey1
addr_fkeyss              r0   r   z-ComponentReflectionTest.test_get_foreign_keys^  s   
 ''FF KK--t{{/J/Jyz"  99AA//

6/JKNE!!33;;= 1E&M<01 '(/:&'4()I;7==EEE/03C2DE **9>>&*I
1::BBD 	4LLvd23	4 	E#$o6E"#UZZ0E$%	{3E'(+;*<='1 1	4 	4s   =G3H 3G= H	c                    | j                  d| j                  j                  j                  z  dt        j
                  j                  z  dt        j
                  j                  z        \  }}}t        | j                        }|j                  |j                        }t        t        |      d       |d   }t        |d   t        j
                  j                         t        |d   |j                         t        |d   d	g       t        |d
   dg       |j                  |j                  t        j
                  j                        }t        t        |      d       |d   }|d   d | j                  j                  j                  fv sJ t        |d   |j                         t        |d   d	g       t        |d
   dg       y )Nz%s.local_tablez%s.remote_tablez%s.remote_table_2   r   ru  rv  rw  r<   rm  r   rB   r   )r4  r  rg   r   r   r   rF   r   r   rY   r   rM  )	rj   r   r   r   rv   local_fkeysr|  remote_fkeysfkey2s	            r0   "test_get_inter_schema_foreign_keysz:ComponentReflectionTest.test_get_inter_schema_foreign_keys  s    59KKtyy00DDD : ::'.."<"<<5
1\> tyy!++K,<,<=Ca AE#$gnn&@&@AE"#^%8%89E$%v.E'(;-8,,gnn&@&@ - 
 	Cq!Q&'II11,
 
 	
 
 	E"#[%5%56E$%v.E'(:,7r2   c                     |D cg c]  }|d   	 }}|D ];  }|d   |v sJ ||j                  |d            }|D ]  }t        ||   ||           = y c c}w )NrY   )indexr   )rj   indexesexpected_indexesdindex_namese_indexr  keys           r0   _assert_insp_indexesz,ComponentReflectionTest._assert_insp_indexes  sy    *12Qqy22' 	.G6?k111K--gfo>?E .GCL%*-.	. 3s   Ac                     |rt         j                  }nd }t        | j                        }|j	                  d|      }dddgdddg dd	dg}| j                  ||       y )
Nr   rB   Fr   r   r
  uniquecolumn_namesrY   )r   r   r   r  )r   rF   r   r  r   r  )rj   ru   r/  rC   rv   r  r  s          r0   r   z(ComponentReflectionTest.test_get_indexes  s|    
 ''FF tyy!""76":  !(' 2%   ='
 	!!'+;<r2   )r   r   )r   r   ztname,ixnamec                    t        |      }|j                  |      }d|dg}| j                  ||       t        |t	               |      }t        t        |j                        d       t        t        |j                        d   j                  |       t        t        |j                        d   j                  |       y )NF)r  rY   autoload_withr  r   )r   r   r  r   r   r   rM  r  r	   listr_  rY   )rj   ru   tnameixnamerv   r  r  r5  s           r0   test_get_noncol_indexz-ComponentReflectionTest.test_get_noncol_index  s     z"""5)
 (-f=>!!'+;<%:>C		NADOA$$a(DOA##V,r2   c                     t        | j                        }|j                  dt        j                  z        }|D ]  }|j                  dd         t        |dgdt        j                  z  dg       y )Nr  duplicates_indexrY   r  )r  rY   )r   r  r   r   rV   popr   )rj   rv   	reflectedrefls       r0   &test_get_temp_table_unique_constraintsz>ComponentReflectionTest.test_get_temp_table_unique_constraints  su     tyy!//0LM	 	/D HH'.	/ 	 &,H,v||;	
r2   c                    t        | j                        }t        t        t        j                  dt        j
                  z        }|j                  |      }|D ]  }|j                  dd         ddgddg}t        j                  j                  j                  rg |d   d<   t        |D cg c]  }|d	   dk(  s| c}|       y c c}w )
Nr  dialect_optionsFr  r  r  r   include_columnsrY   )r   r  r
   r   r.   rV   r   r  r   rD   index_reflects_included_columnsr)   r   )rj   rv   rb   r  indexpectedidxs          r0   test_get_temp_table_indexesz3ComponentReflectionTest.test_get_temp_table_indexes  s    tyy!(FII}v||;

 "":. 	-CGG%t,	- ug}M
 ;;CC-/HQK)*#DSs6{m'CSD	
Ds   -C;Cc                 ~   |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 ],  }|j                  t        j                  |d   d|d   i       . |j                  |       t        |      }t        |j                  d|      t        j                  d            }	t               }
t!        t#        |      t#        |	             t%        ||	      D ]6  \  }}|j'                  dd       }|r|
j)                  |       t!        ||       8 t+               }t        d|||      }	t        |	j,                  D cg c]  }|j.                   c}      }t        |	j0                  D cg c](  }t3        |t        j                        r|j.                  * c}      j5                  dg      }|j7                  |      rJ |
r!t!        |
|       t!        |t                      y y c c}w c c}w )Nunique_aa)rY   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   rY   r  testtblr   r   rB   r  r  )r  rC   )r   rF   r)  operator
itemgetterr   r   r\   r   r   append_constraintr   creater   r   rW  r   rM  rL  r  addr   r  rY   constraintsrQ  
differencerY  )rj   rL   ru   r/  rC   uniquesr_  uc	inspectorr  names_that_duplicate_indexorigr  dupereflected_metadatar  	idx_namesuquq_namess                      r0   r   z3ComponentReflectionTest.test_get_unique_constraints	  s    ''FF#cU;'I'I)E5>J&>(3%@ ##F+

 3		"&3		"&3

#5"))B-(5"))B-(

  	B####R%7IbjI	 	Z J'	,,Yv,F##F+
	
 &)U"CL#i.)gy1 	JD$ 88.5D*..t4dO	 &Z$	
	 Y->->?c?@	 $//b""5"56 
 *n%
& 	 ))(333%*I6#%  & @s   J5:-J:c                     |rt         j                  }nd }d}d}t        |      }|j                  ||      }| j	                  |       |j                  ||      }| j	                  |       y )Nr&  r%  rB   )r   rF   r   r   r  )	rj   ru   r/  rC   
view_name1
view_name2rv   v1v2s	            r0   r   z0ComponentReflectionTest.test_get_view_definitiona  sm    
 ''FF
(
z"%%j%@R%%j%@Rr2   )r   Fr   ztable_name,use_schema
postgresqlzPG specific featurec                     |rt         j                  }nd }t        |      }|j                  ||      }| j	                  t        |t                     y ry   )r   rF   r   get_table_oidr  rQ  int)rj   ru   rb   r/  rC   rv   oids          r0   test_get_table_oidz*ComponentReflectionTest.test_get_table_oids  sF     ''FFz"  V4ZS)*r2   c                     t        | j                        }dD ]A  \  }}|j                  |      }|D ci c]  }|d   |
 c}|   }|j                  dd      rAJ  yc c}w )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.

        ))r   r   )r   r   )r   r   rY   autoincrementTN)r   r  r   get)rj   rv   r  cnamera  r   id_s          r0   test_autoincrement_colz.ComponentReflectionTest.test_autoincrement_col  so     tyy!
 	2LE5
 ##E*D)-.A1V9a<.u5C77?D111	2 /s   Ary   )9r3   r4   r5   run_insertsrun_deletesr   r6   rM   r   rJ   r   rH   r   rD   schema_reflectionr  r  r  r   !foreign_key_constraint_reflectionr   rE   r6  r:  r;  rG   r_   r>  r   rB  rD  r@  r   r  rg  r   rj  !primary_key_constraint_reflectionr   r   r   r  r  r   r   r   r  r   r  temp_table_reflect_indexesr  r   r   only_onr  table_reflectionr  r7   r2   r0   r   r     s    $$K+KN N
 M- M-^ !O !OF N N    ''L (L
 ''L (L ''> (>
 ''M (M 77W"	tUD'"2"2":":;+"	udD'"2"2":":;!	tT4!1!1!9!9:B	*1	 8*1X &&F 'F
 %%&&%%6 & ' &6
 ((" )" ((<  )<
6 W	g&&../	ug&&667$$w'7'7'G'GG	

 (
=6
=6~ ++
+ ,
+ ++,,%%B & - ,B
 W4))112\ 772 82( W4))112\ 77"> 8">H 008  18B. W4))112\==2 W3/
 &&**- + '- ++22
 3 ,
" 00
 1
$ W	w''((\ 22R! 3R!h %%W4))112\ & W	$((001(
 W__\#89+ :+ &&2 '2r2   r   c                      e Zd ZdZdZej                  d        Zej                  d        Zej                  j                  d        Zej                  j                  d        Zej                  j                  d        Zej                  j                  ej                  j                  d               Zej                  j                  ej                  j                  d	               Zy
)TableNoColumnsTest)reflect_tables_no_columnsTc                 >    t        d|       |j                  |       y Nempty)r   
create_allrj   ru   rL   s      r0   table_no_columnsz#TableNoColumnsTest.table_no_columns  s    gx J'r2   c                     t        d|       |j                  |       t        d|       t        j                  |dt	        d             t        j                  |dt	        d             |j                  |       y )Nr  rO   z*CREATE VIEW empty_v AS SELECT * FROM emptyrP   zDROP VIEW IF EXISTS empty_v)r   r  r   rR   r   r  s      r0   view_no_columnsz"TableNoColumnsTest.view_no_columns  sj    gx J'gx <=	
 	mS)F%G	
 	J'r2   c                 n    t        dt               |      }t        t        |j                        g        y )Nr  r  r   r   r   r  r   )rj   ru   r  t2s       r0   test_reflect_table_no_columnsz0TableNoColumnsTest.test_reflect_table_no_columns  s$    7HJjADJr2   c                 L    t        t        |      j                  d      g        y r  r   r   r   )rj   ru   r  s      r0   !test_get_columns_table_no_columnsz4TableNoColumnsTest.test_get_columns_table_no_columns  s    GJ++G4b9r2   c                     t               }|j                  |       t        |j                        j	                  dg      sJ y r  )r   reflectrW  r4  rY  )rj   ru   r  ms       r0   "test_reflect_incl_table_no_columnsz5TableNoColumnsTest.test_reflect_incl_table_no_columns  s3    J			*188}))7)444r2   c                 n    t        dt               |      }t        t        |j                        g        y )Nempty_vr  r  )rj   ru   r  r  s       r0   test_reflect_view_no_columnsz/TableNoColumnsTest.test_reflect_view_no_columns  s&     9hj
CDJr2   c                 L    t        t        |      j                  d      g        y )Nr  r  )rj   ru   r  s      r0    test_get_columns_view_no_columnsz3TableNoColumnsTest.test_get_columns_view_no_columns  s     	GJ++I6;r2   N)r3   r4   r5   __requires__r   r   fixturer  r  rD   r  r  r  r  r   r  r  r7   r2   r0   r  r    s   1LK__( ( __( ($ // 0 //: 0: //5 05
 // 0  //< 0 <r2   r  c                       e Zd ZdZ ej
                  dej                  j                  fdd      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y)ComponentReflectionTestExtraTrk  r/  r"  c           
         |rt         j                  }nd }t        d|t        dt	                     t        j                  dd      t        j                  dd      |       |j                  |       t        |      }t        |j                  d|      t        j                  d	      
      }d }|D cg c]  }|d	    ||d         d }}t        |ddddddg       y c c}w )Nsa_ccr  za > 1 AND a < 5cc1r   za = 1 OR (a > 2 AND a < 5)
UsesCasingrB   rY   r  c                     dj                  t        j                  d| j                         t        j                              S )N zand|\d|=|a|or|<|>)joinrefindalllowerI)sqltexts    r0   	normalizezJComponentReflectionTestExtra.test_get_check_constraints.<locals>.normalize  s.    88

/"$$G r2   r  )rY   r  za = 1 or a > 2 and a < 5za > 1 and a < 5)r   rF   r   r   r   r\   r   r  r   r)  r   r  r  r   )	rj   rL   ru   r/  rC   r  r  r  items	            r0   r   z7ComponentReflectionTestExtra.test_get_check_constraints  s    
 ''FF3	"0u=,< 		
 	J'J'	++GF+C##F+
		 "
 &\iY.HI
	 
 	%2LM+<=	
	
s   7C&c                    t        d|t        dt        d            t        dt        d                  }t        dt	        j
                  |j                  j                        t	        j
                  |j                  j                               t        d|j                  j                         |j                  |       t        |      }ddgdi dg}t        j                  j                  j                  r)g |d	   d
<   d|j                  j                   z  g i|d	   d<   t#        d      5  t%        |j'                  d      |       d d d        y # 1 sw Y   y xY w)Nr5  xr   yt_idxt_idx_2F)rY   r  r  r  r   r  
%s_includer  z>Skipped unsupported reflection of expression-based index t_idx)r   r   r   r   r   r  r   r  r	  r  r   r   rD   r  r)   r  rY   r   r   r   )rj   rL   ru   r5  rv   r  s         r0   %test_reflect_expression_based_indexeszBComponentReflectionTestExtra.test_reflect_expression_based_indexes  s*   3r
#3r
#	
 	gtzz!##%%($**QSSUU*;<iJ'z" "!$#%	
 ;;CC-/HQK)*z00555r.HQK)* L
 	1   %x0	1 	1 	1s   -EEc                 h   t        d|t        dt        d            t        dt        d                  }t        d|j                  j
                        }dg|j                  |j                  j                     d<   |j                  |       t        |      }t        |j                  d      ddgdgdd|j                  j                  z  dgid	g       t        dt               |
      }t        t        |j                        d   j                  |j                  j                     d   dg       y )Nr5  r  r   r	  r
  includeFr  )rY   r  r  r  r  r  r   )r   r   r   r   r   r  r  r  rY   r  r   r   r   r   r  r  )rj   rL   ru   r5  r  rv   r  s          r0   test_reflect_covering_indexz8ComponentReflectionTestExtra.test_reflect_covering_index-  s   3r
#3r
#	
 GQSSUU#BEJ--223I>J'z"S! $%(E(+u#$z'8'8'='==u(
	
 3
*=Q//
0A0A0F0FG E		
r2   c                     t        d|gt        |      D cg c]  \  }}t        d|z  |       c}} }|j                  |       t	        |      j                  d      D cg c]  }|d   	 c}S c c}}w c c}w )Nr5  zt%drH  )r   rN  r   r  r   r   )rj   ru   rL   r   rb  type_r5  r   s           r0   _type_round_tripz-ComponentReflectionTestExtra._type_round_tripS  s{    
 8A7GH81efUQY&H

 	
#*:#6#B#B3#GHa&	HH	 I Is   A3$A9c                     | j                  ||t        j                  dd            D ]J  }t        |t        j                        sJ t	        |j
                  d       t	        |j                  d       L y )N   r   )r  rT  rZ  rQ  r   	precisionscalerj   ru   rL   typs       r0   test_numeric_reflectionz4ComponentReflectionTestExtra.test_numeric_reflection]  sd    (()"3"3B":
 	C c9#4#4555r"		1	r2   c                     | j                  ||t        j                  d            d   }t        |t        j                        sJ t	        |j
                  d       y )N4   r   )r  rT  r   rQ  r   lengthr  s       r0   test_varchar_reflectionz4ComponentReflectionTestExtra.test_varchar_reflectionf  sR    ##)"2"22"6

 #y//000CJJr2   c           
          t        d|t        dt        d      t        dt        d            }|j                  |       t	        t        d t        |      j                  d      D              ddd       y )	Nr5  r  Tr   r  Fc              3   0   K   | ]  }|d    |d   f  yw)rY   r   Nr7   ).0rc  s     r0   	<genexpr>zHComponentReflectionTestExtra.test_nullable_reflection.<locals>.<genexpr>x  s%       Vc*o.s   )r  r  )r   r   r   r  r   r,   r   r   )rj   ru   rL   r5  s       r0   test_nullable_reflectionz5ComponentReflectionTestExtra.test_nullable_reflectionn  so    3$/3%0	
 	
 ":.::3?  U#	
r2   NCASCADEzSET NULLz	NO ACTIONRESTRICTzexpected,ondelete,onupdatec                    i }|r||d<   |r||d<   ||}t        d|t        dt        d      d       t        d|t        dt        d      t        d	t        t        j                  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       |j                  |       t        |      }|j                  d      d   d   t        t        fdD              i        |j                  d      d   d   t        |       y )Nondeleteonupdater  r<   Tr=   r   r_  x_idzx.idxidr   test
   userrY   r@   Fr   tidztable.idmyfkr   r&   c              3   8   K   | ]  }|   s	||   f  y wry   r7   )r!  koptss     r0   r"  zLComponentReflectionTestExtra.test_get_foreign_key_options.<locals>.<genexpr>  s     7!tAw!T!W7s   
)r   r   r   r\   r   r   r   r  r   r   r   r,   )	rj   ru   rL   r  r'  r(  r&   rv   r2  s	           @r0   test_get_foreign_key_optionsz9ComponentReflectionTestExtra.test_get_foreign_key_options  sb   T "*GJ"*GJH4d3		
 	4d367BMM&u$EF66":&	
 	4d366":65'"##*,26= 
	
 	J'z" $$W-a0;D7t77<$$V,Q/	:D(r2   )r3   r4   r5   r   r   r   rD   rE   r   r   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_restrictr3  r7   r2   r0   r  r    s   KW	w''((\ 11+
 2+
Z .."1 /"1H 55#
 6#
JI && ' && ' &&
 '
  WNN		
 NN		
 NN		
 NN		
 NN		
 NN		
 .K&N3O&N3r2   r  c                   0    e Zd ZdZdZed        Zd Zd Zy)NormalizedNameTest)denormalized_namesTc                     t        t        dd      |t        dt        d             t        t        dd      |t        dt        d      t        dt	        d                   y )	Nt1Tr   r<   r=   r  t1idzt1.id)r   r   r   r   r   rK   s     r0   rM   z NormalizedNameTest.define_tables  sU    D)4d3	

 	D)4d36:g./		
r2   c                    t               }t        t        dd      |t        j                        }|j
                  d   }|j                  j                  j                  |j                  j                        sJ t               }|j                  t        j                  d        |j
                  d   j                  j                  j                  |j
                  d   j                  j                        sJ y )Nr  Tr?  r  r>  c                 &    | j                         dv S )Nr>  r  )r  )rY   r  s     r0   <lambda>zINormalizedNameTest.test_reflect_lowercase_forced_tables.<locals>.<lambda>  s    DJJLL,H r2   )only)r   r   r   r   r.   r4  r   r@  
referencesr<   r  )rj   m2t2_reft1_refm3s        r0   $test_reflect_lowercase_forced_tablesz7NormalizedNameTest.test_reflect_lowercase_forced_tables  s    ZD)2VYY
 4xx}}''444Z


IIH 	 	
 yy  %%0041B1B1E1EFFFr2   c                 R   t        t        j                        j                         D cg c]  }|j	                         dv r| }}t        |d   j                         |d   j	                                t        |d   j                         |d   j	                                y c c}w )NrC  r   r  )r   r   r.   r+  r  r   upper)rj   r5  
tablenamess      r0   r6  z'NormalizedNameTest.test_get_table_names  s     VYY'779
wwyL( 

 
 	JqM!:a=#6#6#89JqM!:a=#6#6#89
s   B$N)	r3   r4   r5   r  r   r6   rM   rK  r6  r7   r2   r0   r;  r;    s)    *LK
 
G:r2   r;  c                   \    e Zd Zd Zd Zd Zd Zej                  j                  d        Z
y)ComputedReflectionTestc                     t        t        j                        }|j                  d      }|D ci c]  }|d   |
 }}t	        d|d   d   v        t        |d   d   d        t        |d   d   d        y c c}w )Ncomputed_default_tablerY   42with_defaultrK  normalcomputed_col)r   r   r.   r   r   r	   )rj   rv   ra  r   col_datas        r0   !test_computed_col_default_not_setz8ComputedReflectionTest.test_computed_col_default_not_set
  s    vyy! 89*./QAfIqL//0;;<HXy)40H^$Y/6 0s   A6c                 T   t        t        j                        }|j                  d      }|D ci c]  }|d   |
 }}dD ]  }t	        d||   v        |d   }t	        d|v        t	        d|d   v        t        | j                  |d   d         d       t        d|d   v t        j                  j                  j                         t        j                  j                  j                  r5t        |d   d   t        j                  j                  j                         y y c c}w )	NrR  rY   )r<   rU  rT  computedrV  r  	normal+42	persisted)r   r   r.   r   r   r   r  r   rD   "computed_columns_reflect_persistedr)   "computed_columns_default_persisted)rj   rv   ra  r   r?   r  compDatas          r0    test_get_column_returns_computedz7ComputedReflectionTest.test_get_column_returns_computed  s   vyy! 89&*+&	1++3 	1CJd3i/0	1'
h&'	Xj112DNN8J/	:;[I8J//??GG	
 >>FF$[1  CCKK G ,s   D%c                     t        d||   v        ||   d   }t        | j                  |d         |       t        j                  j
                  j                  rt        d|v        t        |d   |       y y )NrZ  r  r\  )r   r   r  r   rD   r]  r)   r	   )rj   r?   columnr  r\  r_  s         r0   check_columnz#ComputedReflectionTest.check_column(  sp    
d6l*+<
+DNN8I./9>>FFK8+,%y1 Gr2   c                    t        t        j                        }|j                  d      }|D ci c]  }|d   |
 }}| j	                  |ddt
        j                  j                  j                         t
        j                  j                  j                  r| j	                  |ddd       t
        j                  j                  j                  r| j	                  |dd	d
       y y c c}w )Ncomputed_column_tablerY   computed_no_flagr[  computed_virtualznormal+2Fcomputed_storedz	normal-42T)r   r   r.   r   rc  r   rD   r^  r)   computed_columns_virtualcomputed_columns_storedrj   rv   ra  r   r?   s        r0   !test_get_column_returns_persistedz8ComputedReflectionTest.test_get_column_returns_persisted0  s    vyy! 78&*+&	1++??GG		
 44<<"	 33;;!	 < ,s   C&c                    t        t        j                        }|j                  dt        j                        }|D ci c]  }|d   |
 }}| j                  |ddt        j                  j                  j                         t        j                  j                  j                  r| j                  |ddd       t        j                  j                  j                  r| j                  |d	d
d       y y c c}w )Nre  rB   rY   rf  z	normal/42rg  znormal/2Frh  z	normal*42T)r   r   r.   r   rF   rc  r   rD   r^  r)   ri  rj  rk  s        r0   -test_get_column_returns_persisted_with_schemazDComputedReflectionTest.test_get_column_returns_persisted_with_schemaK  s    vyy!#F,>,>   
 '++&	1++??GG		
 44<<"	 33;;!	 < ,s   C6N)r3   r4   r5   rX  r`  rc  rl  r   rD   rE   rn  r7   r2   r0   rP  rP  	  s6    7*26  r2   rP  c                   p    e Zd ZdxZZdZdZed        Zd Z	d Z
ej                  j                  d        Zy)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                  rGt        d|t        dt              t        dt        t        dd            t        j                         y y )Nr>  rU  id1r  id2Tr   r   *      alwaysstart	incrementminvaluemaxvaluecyclecacher   )ry  rz  rB   )
r   r   r   r   r   rD   rE   r)   r   rF   rK   s     r0   rM   z$IdentityReflectionTest.define_tablesp  s    8W%5'8:.		
 		
" ##++x)ugxt2'FG)) ,r2   c                    t         j                  j                  j                  rd}t	        |      D ]  }||vs|j                  |        |rlt        t        |      t        |             |D ]H  }|dk(  rt        ||   ||   k         |dv rt        ||   ||   k\         6t        ||   ||   |       J y t        ||       y t        |d   |d          t        |d   |d          y )Nrx  r|  >   r  r}  rz  r{  )	r   rD   identity_columns_standardr)   r  r  r   rM  r   )rj   valueexpapproxcommon_keysr1  s         r0   checkzIdentityReflectionTest.check  s    55==K %[ !K'IIaL! CJC) 1AJaCF 2333aCF 23E!Hc!fa01 E3gG-k"C$45r2   c                 &   t        t        j                        }|j                  d      |j                  d      z   }|D ]  }|d   dk(  rt	        d|v        |d   dk(  rTt        |d   dv        t        |d	   d        t        d|v        | j                  |d   t        d
ddddd
d      d       u|d   dk(  s~t        |d   dv        t        |d	   d        t        d|v        | j                  |d   t        ddddddd      d
        y )Nr>  r  rY   rU  identityrs  r  TautorK  Fr  rx  Tr  rt  r   r   ru  rv  rw  )	r   r   r.   r   r   r   r   r  r,   ri  s       r0   test_reflect_identityz,IdentityReflectionTest.test_reflect_identity  s@   vyy!%(8(8(>> $	C6{h&s*+V%O,>?C	ND)
c)*

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


O#"#!#!#" !  1$	r2   c                 j   t        t        j                        }|j                  dt        j                        }|D ]t  }|d   dk(  rt        d|v        |d   dk(  s"t        |d   dv        t        |d	   d        t        d|v        | j                  |d   t        d
dddddd      d
       v y )Nr>  rB   rY   rU  r  rs  r  r  rK  Tr   r  r  Frx  r  )
r   r   r.   r   rF   r   r   r   r  r,   ri  s       r0   test_reflect_identity_schemaz3IdentityReflectionTest.test_reflect_identity_schema  s    vyy!V-?-?@ 	C6{h&s*+V%O,>?C	ND)
c)*


O# "#!"!+#    	r2   )r3   r4   r5   r  r  r   r  r6   rM   r  r  r   rD   rE   r  r7   r2   r0   rp  rp  j  sT     $$K+K;L B6:(T  r2   rp  c                       e Zd ZdZed        Zej                  j                  d        Z	ej                  j                  d        Zy)CompositeKeyReflectionTestTc                 2   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		       y )Ntb1r<   attrrY   r   pk_tb1r   Tr   tb2r=   pidpattrpnamer  r  r  fk_tb1_name_id_attr)r   r   r   rT  r^   r\   r   r   r   rY   r<   r  )r/   rL   r  s      r0   rM   z(CompositeKeyReflectionTest.define_tables  s    4!67#69,,R01##FD&xH	
 	4d35'"7G$7I--b12##)SUUXXsuuzz2*
 	
r2   c                     t        | j                        }|j                  | j                  j                  j
                        }t        |j                  d      g d       y )Nrm  rY   r<   r  )r   r  r   r4  r  rY   r   r  )rj   rv   r>   s      r0   test_pk_column_orderz/CompositeKeyReflectionTest.test_pk_column_order  sE     tyy!,,T[[__-A-ABKOO124JKr2   c                 4   t        | j                        }|j                  | j                  j                  j
                        }t        t        |      d       |d   }t        |j                  d      g d       t        |j                  d      g d       y )Nr  r   rw  r  rm  r  )	r   r  r   r4  r  rY   r   rM  r  )rj   rv   foreign_keysr|  s       r0   test_fk_column_orderz/CompositeKeyReflectionTest.test_fk_column_order  sr     tyy!,,T[[__-A-ABCq!QEII()+ABEII+,.GHr2   N)r3   r4   r5   r   r6   rM   r   rD   r  r  r  r  r7   r2   r0   r  r    s]    K
 
6 77L 8L 77I 8Ir2   r  )
r   r  r  r   r9   r   r;  rP  rp  r  )5r  r   r*   r\   r   r   r   r   r   r   r	   	provisionr
   r   rC   r   r   r   r   r   r   r   r   r   r   r   r   rT  r   r   sql.elementsr   
sql.schemar   r   r   rL   r   
TablesTestr    r9   r   r   r   TestBaser  r  r;  ComputedReflectionFixtureTestrP  rp  r  __all__r7   r2   r0   <module>r     sB    	        + /            "   ' &   %h11  G:* G:T88&& 8vN0X00 N0bO25 O2d4<** 4<nF8#4#4 FT):,, ):X^XCC ^BGX00 GT.I!4!4 .Ibr2   