gddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl#m%Z%ddlm&Z&dd lm'Z'dd!l(m)Z)dd"l*m+Z+dd#lm,Z,dd$lm-Z-dd%lm.Z.dd&lm/Z/dd'lm0Z0d(\Z1Z2Gd)d*e jfZ4Gd+d,e4Z5Gd-d.e jfZ6Gd/d0e jnZ8Gd1d2e jfZ9d3Z:Gd4d5e-e4Z;Gd6d7e jnZ<Gd8d9e,e jnZ=Gd:d;e jfZ>Gd<d=e j~Z@Gd>d?e jfZAGd@dAe jfZBdBZCy)CN)config)engines)eq_) expect_raises)expect_raises_message)expect_warnings)fixtures)is_)get_temp_table_name)temp_table_keyword_args)Column)Table)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)mockNNceZdZedZy)OneConnectionTablesTestctjjjr1ddlm}t jt|jdStjS)Nr)poolclass) poolclassscope)options) r requirementsindependent_connectionsenabled sqlalchemyr-rtesting_enginedict StaticPooldb)clsr-s Y/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/testing/suite/test_reflection.py setup_bindz"OneConnectionTablesTest.setup_bind8sI    6 6 > > '))tgF 99 N)__name__ __module__ __qualname__ classmethodr<r=r;r+r+7s  r=r+cBeZdZdZedZedZedZedZdZ dZ e jjdZe jjd Ze jj d Ze jj$d Ze jj$e jj(e jj*d Ze jj e jjd Zy) HasTableTestTc td|tdtdtdtdtj j jrAtd|tdtdtdtdtjtj jr|j|tj jjr|j|yy) N test_tableidT primary_keydata2 test_table_sschema)rrrrrrequiresschemasr4r test_schemaview_reflection define_viewshas_temp_tabledefine_temp_tablesr:metadatas r; define_tableszHasTableTest.define_tablesJs   4d 3 66": &     # # + + tW$7vvbz*))      + +   X &    * * 2 2  " "8 , 3r=cd}tj|dt|tj|dtdtjj j rwdtjdtjd}tj|dt|tj|dtdtjzyy) 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_szDROP VIEW %s.vv) rlistenr rrOrPr4rrQ)r:rWquerys r;rSzHasTableTest.define_views`sC X~s5z: X}c..AB    # # + +&&&&  LL>3u: > LL%););<=  ,r=cbtttjdtjSN user_tmp_r rr9identr:s r;temp_table_namezHasTableTest.temp_table_namev%" FII6<<.9  r=c "tttj}|j}t ||t dt jdt dt jdfi|}tjjjrwtjjjrRtj|dt!dtj"ztj|dt!d yyy) NrGTrHnamerKrZ=create temporary view user_tmp_v as select * from user_tmp_%sr[drop view user_tmp_v)r rr9rerrsaINTVARCHARrrOrRr4temporary_viewsrr]r rcr:rWkw table_nameuser_tmps r;rUzHasTableTest.define_temp_tables|s $VVYY 7((*    4T 2 62::b> *        , , 4 4  0088 LL028,,?  LL=#6L2M N9 5r=ctjj5}ttjjj |dt tjjj |dt tjjj |ddddy#1swYyxYw)NrFrLnonexistent_table)rr9beginr'dialect has_tabler&selfconns r;test_has_tablezHasTableTest.test_has_tables| YY__ $ FII%%//lC D VYY&&00~F G VYY&&007JK L  s BCC c"ttj}t|j dt d|t dt}t|j d|jtj t|j d|jt|j d|jtjy#|jtjwxYw)NrF new_tablecol) rrr9r'rwrrrr&create clear_cachedrop)ryrWinspnts r;test_has_table_cachez!HasTableTest.test_has_table_cachesvyy!|,- ;&*@ A ,- &))  T^^K0 1     DNN;/ 0 GGFII BGGFII s AC--!Dctjj5}ttjjj |dtj ttjjj |dtj ttjjj |dtj dddy#1swYyxYw)NrFrMrLrt)rr9rur&rvrwrQr'rxs r;test_has_table_schemaz"HasTableTest.test_has_table_schemas YY__ $  !!++,v/A/A,   !!++.1C1C,   !!++-f6H6H,   s C C22C;ctjj5}ttjjj |dddddy#1swYyxYw)NrFnonexistent_schemarM)rr9rur&rvrwrxs r;!test_has_table_nonexistent_schemaz.HasTableTest.test_has_table_nonexistent_schemasK YY__ $  !!++,/C,   s 6AA'cNt|}t|jdyNvvrr'rwry connectionrs r;test_has_table_viewz HasTableTest.test_has_table_viewsz"t$%r=cnt|}|j}t|j|yN)rrer'rw)ryrrres r;test_has_table_temp_tablez&HasTableTest.test_has_table_temp_tables+z"..0/0r=cNt|}t|jdyN user_tmp_vrrs r;test_has_table_temp_viewz%HasTableTest.test_has_table_temp_viewsz"|,-r=clt|}t|jdtjyr)rr'rwrrQrs r;test_has_table_view_schemaz'HasTableTest.test_has_table_view_schemas'z"tV%7%789r=N)r>r?r@ __backend__rArXrSrerUr{rrrOrPrrviewsrrTrrRrnrrrBr=r;rDrDGs^K--**  OO0M  $  && $$1%1  $$ %% %%.&&%.  ::r=rDceZdZdZdZedZejdddZ dZ e d Z ejje d Zy ) HasIndexTestT)index_reflectionc td|tdtdtdtdtdtd}t d|j j tjjjrbtd|tdtdtdtdtj }t d |j j yy) NrFrGTrHrJrKdata2my_idxrMmy_idx_s) rrrrr!crJrrOrPr4rrQ)r:rWtts r;rXzHasIndexTest.define_tabless    4d 3 66": & 7F2J '   h "    # # + +tW$7vvbz*)) B *bddii ( ,r=rv inspectorkindargnamescB|dk(rfdStjS)Nrvc^tjjjg|i|Sr)rr9rv has_index)akrzs r;z)HasIndexTest._has_index..s$699#4#4#>#>t#Ma#M1#Mr=)rr)ryrrzs `r; _has_indexzHasIndexTest._has_indexs! 9 M M4=** *r=c |j||}|ddsJ|ddrJ|ddrJ|ddrJ|ddrJ|ddrJtd|jjjj }t d|td ttdd }|j||j| |d k(r0|ddrJ|ddrJ|jj|ddd usJ|ddd usJ |j||j|y#|j||j|wxYw) NrFrrrtnonexistent_idxmy_idx_2 test_table_2my_idx_3foorT) rr!tablesrFrrrrrr__self__rr)ryrrrWmethidxtbls r;test_has_indexzHasIndexTest.test_has_indexsotZ0L(+++ j111+X666 &7888 j111 333J 6 6 8 8 > >?   5' " *e $   : : !{" j999 ;;; ))+ j1T9 99 3t; ;; HHZ HHZ  HHZ HHZ s AE$E)c|j||}|ddtjsJ|ddtjrJ|ddtjrJ|ddtjrJy)NrFrrMrrtnonexistent_idx_s)rrrQ)ryrrrs r;test_has_index_schemaz"HasIndexTest.test_has_index_schemastZ0L*V5G5GHHH hv7I7IJJJ F4F4F    -f6H6H    r=N)r>r?r@r __requires__rArXr combinationsrrrrOrPrrBr=r;rrswK(L))( 7   ; HD+  ! !:       r=rc eZdZdZdZdZejddddd ejd dd gejd d ddd dZ y) BizarroCharacterFKResolutionTestztests for #10275T)!foreign_key_constraint_reflection)rG)z(3))zcol%p)z[brack] columnnamer use_compositeF)plain)z(2))z per % cent)z [brackets] tablenamec `t||t|tddd}|r!|jtdtd|rtd|tdtdtdttd tt j dd g|j j|j jgdnGtd|tdtdtdt|j jd|j|t}td|| }|j|} |j jj| j d sJ|r5|j jj| j d sJyy) NrGT)keyrI test_needs_fkid2rHotherrefref2 autoload_withr)rrr append_columnrkForeignKeyConstraintrrGrr create_allrrr referencesr) ryrrWrrrrm2o2t1s r; test_fk_refz,BizarroCharacterFKResolutionTest.test_fk_ref0sW   :wDd C      VE7E F  tW$7ug&vw'''"$$''244889LM"  tW$7uj12"   J' Z 7Bj 9 YYy !ttxx""2447+++ 4499''Q0 00 r=N) r>r?r@__doc__rrrr variationrrBr=r;rr*szK9LW:|lWu 6W (17(1r=rceZdZdZdZedZdZedZee jjdZ edZ edZee jjd Zee jj"d Zee jj&d Zee jj*d Zee jj.d Zy)QuotedNameArgumentTestonceTc6td|tdttdtdtdtdtdtt j ddt j d dt jdd t jdgd gd t jd ddd tjjjrtd|tdttdtdtdtdtdtt j ddt j ddt jddt jdgd gdt jd ddd td|tdtdtdtdtjjjrtjjjrddg}ndg}|D]}dtj j"j$j'd|zdtj j"j$j'|}t)j*|dt-|t)j*|d t-d!tj j"j$j'd|zzyy)"N quote ' onerGrhrKrJ related_idzpk quote ' onerhzix quote ' onez uq quote' onez related.idzfk quote ' onez name != 'foo'zck quote ' onezquote ' one commentT)commentr quote " twozpk quote " twozix quote " twoz uq quote" twozfk quote " twozck quote " two zquote " two commentrelatedrHrr\view %s AS SELECT * FROM rZr[z DROP VIEW %s)rrrrrkPrimaryKeyConstraintr!UniqueConstraintrCheckConstraintrrOsymbol_names_w_double_quoter4view_column_reflectionrr9rvidentifier_preparerquoterr]r )r:rWnamesrhr^s r;rXz$QuotedNameArgumentTest.define_tablesjs   4 ! 66": & 66": & < )  # #D/? @ HH%v .   $   # #-=    5E F.% *    7 7 ? ? tW%vvbz*vvbz*|W-''3CD)62##(''F\N1A""?9JK2"% *    4d 3 9g &      2 2 : :;;CC!! "II%%99??!D(II%%99??E  X~s5zB !& ))++??EE%,  ;r=cntjddtjjf|S)N)rr)rrrOr)fns r;quote_fixturesz%QuotedNameArgumentTest.quote_fixturess: w##  G,,HH I   r=c>ttj}tjj j r+|j|}tt|tytt5|j|}dddy#1swYyxYwr) rrr9rrOreflect_table_optionsr4get_table_optionsr' isinstancer7rNotImplementedError)ryrhrress r;test_get_table_optionsz-QuotedNameArgumentTest.test_get_table_optionssivyy!    1 1 9 9((.C JsD) *23,,T2433s 8BBcbttj}|jd|zsJy)Nr)rrr9get_view_definitionryrhrs r;test_get_view_definitionz/QuotedNameArgumentTest.test_get_view_definitions+vyy!'' D(8999r=c\ttj}|j|sJyr)rrr9 get_columnsrs r;test_get_columnsz'QuotedNameArgumentTest.test_get_columnss$vyy!%%%r=c\ttj}|j|sJyr)rrr9get_pk_constraintrs r;test_get_pk_constraintz-QuotedNameArgumentTest.test_get_pk_constraints$vyy!%%d+++r=c\ttj}|j|sJyr)rrr9get_foreign_keysrs r;test_get_foreign_keysz,QuotedNameArgumentTest.test_get_foreign_keyss&vyy!$$T***r=c\ttj}|j|sJyr)rrr9 get_indexesrs r;test_get_indexesz'QuotedNameArgumentTest.test_get_indexess&vyy!%%%r=c\ttj}|j|sJyr)rrr9get_unique_constraintsrs r;test_get_unique_constraintsz2QuotedNameArgumentTest.test_get_unique_constraintss&vyy!**4000r=c\ttj}|j|sJyr)rrr9get_table_commentrs r;test_get_table_commentz-QuotedNameArgumentTest.test_get_table_comments&vyy!%%d+++r=c\ttj}|j|sJyr)rrr9get_check_constraintsrs r;test_get_check_constraintsz1QuotedNameArgumentTest.test_get_check_constraintss&vyy!))$///r=N)r>r?r@run_create_tablesrrArXrrrrOrrrrrrrr unique_constraint_reflectionr comment_reflectionrcheck_constraint_reflectionrrBr=r;rrfsSKPPd 33 ,,:-:&&,, 77+8+ &&&'& 22131 ((,), 11020r=rc tjddtjjfd}tjtj tj tjd}tjtjtjtjtjtjtjtjztjtjzd}tjddd}|||||S) Nc"tjSr)rrQrBr=r;rz$_multi_combination..s F&&r=rNrr0rTF use_filter) rrrOrPrDEFAULT TEMPORARYANYrTABLEVIEWMATERIALIZED_VIEWANY_VIEW)rrNr0r filter_namess r;_multi_combinationr#s  ! ! &    $ $  F    E   $$:??*:777 D''elKL %\"-./ 00r=c HeZdZdxZZdZedZedZedZ edZ edZ dZ d Z d Zdej ej dfd Zdej ej dfd Zdej ej dfd ZedZdej ej dfdZedZdej ej dfdZedZdej ej dfdZedZdej ej ddfdZedZdej ej dfdZedZ e!jDjFdZ$e!jDjFdZ%e!jDjFdZ&e!jDjFdZ'e!jDjFe!jDjPdZ)e!jDjFdZ*e!jDjFd Z+e!jXdd!e!jDjZfd"#e!jXde!jDj\fdd$#d%Z/e!jXde!jDj\fdd$#d&Z0e!jDjbd'Z2e!jDjfe!jDjhd(Z5e!jDjld)Z7e!jDjle!jDj\d*Z8d_d+Z9e!jXd,dde!jDj\fdde!jDjffdde!jDj\e!jDjfzfd-#d.Z:e!jDjvd/ZZOe!jDjfd?ZPe!jDjd@ZRe!jXde!jDj\fd2d$#dAZSe!jXde!jDj\fddBZTe!jdCZVe!jDjeXdDZYe!jDjleXdEZZdFZ[d`dGZ\dadHZ]eXdIZ^e!jDjeXdJZ_dKZ`e!jDjZeXdLZae!jDjeXdMZbe!jDjeXdNZce!jDjeXdOZee!jXdPe!jDjfdQdRe!jDjfdSe!jDjZfdTe!jDjfdUe!jDjfdVe!jDjfdWe!jDjlfdX# dYZfdZZge!jXddd$#e!jXde!jDjfdd[#d\Zie!jDjld]Zje!jDjd^Zly)bComponentReflectionTestNTc|j|dtjjjr+|j|tj j yyr)define_reflected_tablesrrOrPr4rrQrVs r;rXz%ComponentReflectionTest.define_tables sF ##Hd3    # # + +  ' ''..2L2L M ,r=c |r|dz}nd}tjjjrt d|zdf}nd}t d|t dtjd t d tjd d t dtjd t dtjg|tjdddtjd|d  }t d|t dtjd t dtjt d|zddt dtjt d|zt dtjdd tjd!d"tjddd#d$|d  t d%|t dtjt d&tjt |jj t d'tjd(d )tj"dd*d+|d t d,|t d-tjd d./t dtjd(d01t d2tjd(d31t d4tjd5d61|d78t d9|t dtjd(|d:8tjj$jre|t d;|t d-tjd t dtjd(t dnt d?|t d-tjd t d@t dAt&j*j,j.zt dtjd(|d t dB|t d-tjd t dtjd(|d tjj0jrt3dC|jj4|jj6d t3dD|jj |jj6|jj4|st dE|t dFtjd d G}t dH|t d-tjd t dFtjd d G}tjj8jrtjj:jr\t3dI|jj<j?t3dJ|jj<j?tjj@jr|jC|||s7tjjDjr|jG|yyy)KN.z%susers.user_id user_id_fkrrBusersuser_idTrHtest1Fnullabletest2parent_user_id test2 > 0zz_test2_gt_zerousers check constraintrhr test2 <= 1000rNr dingalings dingaling_id address_idz%semail_addresses.address_idzz_email_add_id_fg di fk commentid_userrJ)uniquez$address_id > 0 AND address_id < 1000address_id_gt_zerozz_dingalings_multipledi unique commentemail_addressesremote_user_id email_address)index email_ad_pk ea pk comment comment_testrG id comment)rIrdata % commentrd2)Comment types type speedily ' " \ '' Fun!d3*Comment with escapesthe test % ' " \ table comment)rNrno_constraints"no constraints has escaped comment local_table remote_idz%s.remote_table_2.id)rrN remote_tablelocal_idz%s.local_table.idremote_table_2 users_t_idx users_all_idxnoncol_idx_test_nopkqrnoncol_idx_test_pknoncol_idx_nopk noncol_idx_pk)$rrOself_referential_foreign_keysr4rrrrkrlCHARFloatrrrrrr-rcross_schema_fk_reflectionrrQr9rvdefault_schema_namerr!r.r2indexes_with_ascdescreflect_indexes_with_ascdescr`descrrStemp_table_reflectionrU)r:rWrN schema_prefixparent_id_argsr,r_ras r;r'z/ComponentReflectionTest.define_reflected_tables&s4 "SLMM    9 9 A A% 5LN  N   9bff$ 7 7BGGAJ 7 7BHHJ 7 #RZZ A. A   '0     / "    >2::4 @  2]B-+   ,}<=  6299R= 6   6)    -+   = @    < , #RZZEGGOO1L M ?BIIbM >  # #=/      4| L 6299R=2B C  " H  420H I9     6299R= )<      6 6 > >~!4>6299R=1#"2W^^5O5OO #'!99,,@@ "4>""/$ii//CCD6299R=1!"&$4>6299R=1!"&     , , 4 4 - d K %''-- ',*3 ! -"& ($&+(4>3 ! -"& &"$$99AA((EEMM+-A-C-C-E-E-J-J-LM/+=+?+?+A+A+F+F+HI    2 2 : :   Xv .'**@@HH  " "8 ,Ivr=cbtttjdtjSr`rbrds r;rez'ComponentReflectionTest.temp_table_namerfr=c tttj}|j}t ||t dt jdt dt jdt dt jt jddtjt jd dfi|}tjjjrwtjj jrRt#j$|d t'd tjzt#j$|d t'd yyy)NrGTrHrhrKr user_tmp_uq_r user_tmp_ixrZrir[rj)r rr9rerrrkrlrmrrcr!rrOrRr4rnrr]r ros r;rUz*ComponentReflectionTest.define_temp_tabless $VVYY 7((*    4T 2 62::b> * 5"&& !   |FLL>-J K HH]E *  "    , , 4 4  0088 LL028,,?  LL=#6L2M N9 5r=c tjjjrdh}n t }dD]}|}|r|d|}|dz}||vrdnd}d|d|d |}t j |d t|||vrId } |rtjd r|d| } d | d|d} t j |d t| t j |dtd|d|y)Nr:r,rEr:r)_vz MATERIALIZED r*zCREATE zVIEW rrZ mat_indexoraclez CREATE INDEX z ON z(data)r[zDROP ) rrOmaterialized_viewsr4setrr]r against) r:rWrN materializedrqfullname view_nameprefixr^ index_namers r;rSz$ComponentReflectionTest.define_viewss     . . 6 6(>L5LDJ!H$XQzl3 4I(2l(B_F&yk1CH:N  LL>3u: >\)( gooh7$*81ZL!9J%j\i[G X~s3x@ LL-uVHE)-M)N #Er=ci}tj|vr|j|tj|vr|j|tj|vr|j||Sr)rrupdaterr )ryrrrr{rs r; _resolve_kindz%ComponentReflectionTest._resolve_kindsX   t # JJv  ??d " JJu   ' '4 / JJ| $ r=ctjjjs!|j |j ytjj js"|j ||j yyr)rrOrr4clearrxr)ryrr{s r;_resolve_viewsz&ComponentReflectionTest._resolve_views!s^66>>    KKM!!44<< LL &    =r=c d}|tjurd}|tjurd}dddhtjj dddd |j hi}tjjjsB|djd|tjj jddgtjjjs|djddgtjjjr$tjjjs$|djd |j gtjjjs|djd g|j!Dcic]#\}}||r|d ||vr |r|d |vr||%} }}| Scc}}w) Ncy)NTrB)_s r;rz8ComponentReflectionTest._resolve_names..*sr=cd|dvSNtmprrBrs r;rz8ComponentReflectionTest._resolve_names..,s U!A$%6r=cd|dvSrrBrs r;rz8ComponentReflectionTest._resolve_names...s Uad]r=rZr\rXr_rarr)rrrrrrQrerOrgr4addrrrltemp_table_namesrnitems) ryrNr0r"values scope_filterremovedrvrs r;_resolve_namesz&ComponentReflectionTest._resolve_names)s% K'' '6L K)) )2L >#34 NN & &&$$$& )  ::BB DM  m , GNN.. / 6 6!12 0088 DM ')=>   66>>##44<< DM ,0D0D0F!G H//77 DM , 0  &1A!GFO+!QqT\%9 qD&    s9(G&c|dftji}|dftj|dftj|dftji}|j|||dftj|dftj|dftj|dftj|d ftj|d ftj|d ftj|d ftj|d ftj|dftj||jftji }|j ||||}|j ||||}|S)N dingalings_vemail_addresses_vusers_vrr,r:rErLrVrXrZr\r_rar(rrrerr) ryrNr0rr"r{rrrs r; exp_optionsz#ComponentReflectionTest.exp_optionsTs= 0$((; ( )488 Y  \ "DHH  E<0 W txx \ "DHH & ' ^ $dhh % & ] #TXX ^ $dhh % & + ,dhh ) *DHH T))+ ,dhh    vulC!!&%sC r=c*ddi}|df|i}|df||df||df|i}|j|||df||df||df||d fdd i|d fdd i|d f||df||df||df||df|||jf|i }|j||||} |j|||| } | S)Ntextrrrrr,r:rErLrUrVrWrXrZr\r_ra)rrerr) ryrNr0rr"emptyr{rrrs r; exp_commentsz$ComponentReflectionTest.exp_commentsss 0%8 ( )5 Y  \ "E  E<0 W u \ "E & ' ^ $='% &@)] #U ^ $e % & + ,e ) *E T))+ ,e "  vulC!!&%sC r=c dtjddfd fd}|df ddtj d  d  d gi}|d f d dtj d  dg|df ddtj dtj dtj dg|df ddtj d dgi}|j|||df|d dd dd dg|df|d d  d  d g|df|d  d  dg|df|dd 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||jf|d d dgi }|j ||||} |j |||| } | S)-NFTc`||tj|||d}|dk(r|jd|S)N)rh autoincrementtypedefaultrr1omitr)r(rpop)rhautorrr1rs r;r~z0ComponentReflectionTest.exp_columns..cols;!%""$ Cv~(Jr=cBdtjdd|}|fi|S)NTF)rrr1r(r)rhrpr~s r;pkz/ComponentReflectionTest.exp_columns..pks&488M"MBt?r? "r=rr;r)rr1r<r?rJrrFrGrr-r.r0r2r3rrGrhrr,r:rErLrMrOrNrPrQrRrTrVrXrYrZr[r\r_r`rar) ryrNr0rr"rr{rrrr~s @r; exp_columnsz#ComponentReflectionTest.exp_columnssdhht  # ^ $N$((CL!IF ' ( )LvA$%O$, Y IFTXX>Gdhh/Gdhh/$% " \ "Dv9F E % $ E<0 W 9 Ge,Ge,$%   \ ">"L!IF % & '< $%O$* ^ $4.F$45LD":;'% &V ] #bhF S=M%N ^ $r$xZ#f+&N % &D3v;(? + ,s3xj ) *RXs3x,@ T))+ ,4F E /C& N  vulC!!&%sC r=c hdS)N>rhrrr1rBrys r;_required_column_keysz-ComponentReflectionTest._required_column_keyss66r=ctjddd}|d}tjjj r |df|di}n|df|i}|df||df||df|i}|j |||d f|d |d f|d|d f|d dd|df|d|df||df|d|df|d|df|d|df||df|d||jf|di } tjjj s.| jD]} | d tj| d<|j|| ||} |j|||| } | S)Nr7c t|||dS)N)constrained_columnsrhr)list)rhrcolss r;rz+ComponentReflectionTest.exp_pks..pks'+Dz" r=rrr;rrrr,r-r:rEr<rJrKrLrGrVrXrZr\r_rarh) r(rrrOmaterialized_views_reflect_pkr4rrereflects_pk_namesrrr) ryrNr0rr"rrr{rrvalrs r;exp_pkszComponentReflectionTest.exp_pkss 88T      9 9 A A#^4b6HIL#^4e.ttc\|duxs'tjjj|k(Sr)rr9rvrh)ryrs r;__eq__z2ComponentReflectionTest.exp_fks..tt.__eq__7s,TMFyy((<<Er=Nr>r?r@rrBr=r;rr6s r=rcF|||tj||n||dS)N)rreferred_columnsrhr1referred_schemareferred_tablerr)rref_col ref_table ref_schemarhrrs r;fkz+ComponentReflectionTest.exp_fks..fk=s1(,$+88","8Jbd"+"  r=rrrrr,r3r-r+rr:r?r<rEr=r>r7rFrLrVrXrYrGr\)rrZr[r_rarh)r(rrrrQrerrOrdr4rnamed_constraintsrrr) ryrNr0rr"rr{rrvalsrrrs @r;exp_fkszComponentReflectionTest.exp_fks/s5    ( 0"5 ( )2 Y  \ "B  E<0 W $% {G,O \ "I; W5!N!N%-+  %& '$% {G<*^ $b % & ] # MF$%11 &^ $J<$4H'% & + ,b ) *B T))+ ,bC" F==EE FG$ % + + -1199 C6{$((2&*hhF  (   vulC!!&%sC r=c hdS)N>rhrrrrrBrs r;_required_fk_keysz)ComponentReflectionTest._required_fk_keyss   r=c^dddddd}|dfgi}|dfg|dfg|dfgi}|j|||r||dfj|dd |d fg|d d d|dddd |dddd|dfg|dtjdd|dtjd|ddddd|dfg|dtj |dtjd|dfg|d fg|d!fg|d"tjd|d#fg|d$tjd|d%fg|d&fg|d'd(d'd)i*|d+fg|d'd,d'd)i*||j fg|d-d. |d/d0t j dd1i }tjjjr$tjjjs*||d&fj||d+fj|j||||} |j|||| } | S)2NF)rAcolumn_sorting duplicatesrctjj}tjj}tjj}|r |j r|r |j sy|t ||tjgd} |r4|| d<|j r#| dx| d<} | D cgc] } | |vrdn|  c} | d<|r|| d<| gScc} w)NrB)rA column_namesrhdialect_optionsinclude_columnsrr expressionsduplicates_constraint) rrOforeign_keys_reflect_as_index#unique_constraints_reflect_as_index*reflect_indexes_with_ascdesc_as_expressionr4rr(r) rhrArrrrfk_reqdup_reqsorting_expressionrorigrs r;rz0ComponentReflectionTest.exp_indexes..idxs%%CCF&&JJG  KK 6>>7?? $T #'88#% C(6$%%--03N0CCC &DH+DHq^ 3:D+C'/3+,5L +s,C rrrrrJrvrr,r3r+T)rhrr-r2r.r^r])rhrAr:)rhrArr?r<r;rCrErGrFrLrVrXrYrZr[r\r_r`rb)rk)rhrrarcrrrrhrq)rhrrA)rextendr(rrerrcrrOrir4rjrrr) ryrNr0rr"rr{rrrs r; exp_indexesz#ComponentReflectionTest.exp_indexess # J 0"5 ( )2 Y  \ "B  E<0  &.1 2 9 9F- W  %LTB YG WgM$G  \ " %V$((4DI %YTXX$7 % "1#  %& '*_4884*%DHH>*^ $b % & ] #&[txxD9&^ $'Zdhh48'% & + ,/*$'#3/) *-osI>N- T))+ ,/U//' ~6# /U3 j  55==##@@HH F23 4 : : < F01 2 8 8 :  vulC!!&%sC r=c hdS)N>rhrArrBrs r;_required_index_keysz,ComponentReflectionTest._required_index_keyss11r=Fcddddd}|dfgi}|dfg|dfg|dfgi}|j|||dfg|d d d d d |dfg|dtjtj|ddddd|dfg|dfg|dfg|dfg|dfg|dfg|dfg|dfg||jfg|ddtj  i } |ri||| S|j || ||} |j|||| } | S)!NF)duplicates_indexis_indexrctjj}|r |jsyt |||d}|r||d<|gS)NrB)rrhrr)rrO*unique_index_reflect_as_unique_constraintsr4r)rhrrrrreqrs r;ucz+ComponentReflectionTest.exp_ucs..ucsL""MMC  $T "C  *:&'5Lr=rrrrr,r.r2r]T)rhrrr:rJ)rhrr<r;rCrD)rhrrrErLrVrXrZr\r_rarhrqr)rr(rrerrcrr) ryrNr0rr"all_rr{rrrs r;exp_ucszComponentReflectionTest.exp_ucs s+/  0"5 ( )2 Y  \ "B  E<0 W  &%2!  \ " %FDHHE % "1%=/  %& ' ^ $b % & ] #R ^ $b % & + ,b ) *B T))+ ,/F< ~!>?/9 @ 6l6e6v6 6$$T65,GC%%fe\3GCJr=c ddhS)NrhrrBrs r;_required_unique_cst_keysz1ComponentReflectionTest._required_unique_cst_keysOs ''r=c Gddt d fd }|dfgi}|dfg|dfg|dfgi}|j|||df|d tj|d d d g|df|ddg|dfg|dfg|dfg|dfg|dfg|dfg|dfg|dfg||j fgi }|j ||||} |j |||| } | S)NceZdZdZy)+ComponentReflectionTest.exp_ccs..ttc|jjddjddjdd}||vS)N(r*)`)lowerreplace)ryrrs r;rz2ComponentReflectionTest.exp_ccs..tt.__eq__[s@KKMWS"%WS"%WS"%  s{"r=NrrBr=r;rrZs #r=rc|||dS)N)sqltextrhrrB)rrhrrs r;ccz+ComponentReflectionTest.exp_ccs..ccds!$x'J Jr=rrrrr,r8r4r5r6rOr:z$address_id > 0 and address_id < 1000rBrrErLrVrXrZr\r_rar)strrr(rrerr) ryrNr0rr"rr{rrrrs @r;exp_ccszComponentReflectionTest.exp_ccsSsK # # K  0"5 ( )2 Y  \ "B  E<0 W ?DHH-&4 \ ":-% & ' ^ $b % & ] #R ^ $b % & + ,b ) *B T))+ ,b/ 2  vulC!!&%sC r=c ddhS)NrhrrBrs r;_required_cc_keysz)ComponentReflectionTest._required_cc_keyss  ""r=ct|}ttjj|j vyr)rr'rrrQget_schema_namesrs r;test_get_schema_namesz-ComponentReflectionTest.test_get_schema_namess,z"**d.C.C.EEFr=ct|}t|jtjj t |jdy)Nsa_fake_schema_foo)rr' has_schemarrrQr&rs r;test_has_schemaz'ComponentReflectionTest.test_has_schemas9z" : :;<!567r=c|jddttjji}t |}t tjj|jvy)z test #7300rbarschema_translate_mapN)execution_optionsr#rrrQrr'rrs r;%test_get_schema_names_w_translate_mapz=ComponentReflectionTest.test_get_schema_names_w_translate_maps^ 11ugnn88"2 z"**d.C.C.EEFr=c|jddttjji}t |}t |jtjjt|jdy)Nrrrr) rr#rrrQrr'rr&rs r;test_has_schema_w_translate_mapz7ComponentReflectionTest.test_has_schema_w_translate_mapsi11ugnn88"2 z" : :;<!567r=c t|}td|jvt|jd|j t d td|jvt|jd|j td|jvt|jd|j t dy#|j t dwxYw)Nfoo_barzCREATE SCHEMA foo_barzDROP SCHEMA foo_bar)rr&rrexecuter rr'rs r;test_schema_cachez)ComponentReflectionTest.test_schema_cachesz"d33556+,3678 ; Y$"7"7"99 : T__Y/ 0     I!6!6!88 9 DOOI. /   s#89 :J  s#89 :s A:C11D crtj}t|t|jdsJy)Nrh)rr6rhasattrrv)ryengines r;test_dialect_initializez/ComponentReflectionTest.test_dialect_initializes,'')v~~'<===r=cnt|}t|j|jjyr)rrrhrvrs r;test_get_default_schema_namez4ComponentReflectionTest.test_get_default_schema_names(z" D $ $j&8&8&L&LMr= foreign_keyorder_byr use_schemacZ|rtj}nd}hd}t|}|r'|j|Dcgc] }|dr|d}}n|j |}|D cgc] } | |vs|  } } |dk(rgd} t | | ygd} t t | | ycc}wcc} w)N>rXrLrZrVr\rar_rrrt)r:rEr,)rrQrget_sorted_table_and_fkc_namesget_table_namesrsorted) ryrrrrN_ignore_tablesrrecrt table_namesanswers r;test_get_table_namesz,ComponentReflectionTest.test_get_table_namess ''FF z"  >>vFFCq6AF  ))&1F"(D&QA^,Cq& D } $?F  V $?F {#V ,EsB## B(-B(cHt|}|rtj}nd}|j|}tj j jr4tt|ddgt|j|dgygd}tt||y)Nrrr)rrr) rrrQget_view_namesrrOrxr4rrget_materialized_view_names)ryrrrrNrr s r;test_get_view_namesz+ComponentReflectionTest.test_get_view_namessz" ''FF))&1    . . 6 6 {#&99%E F 008>:J KEF {#V ,r=ct|}|j}tt|dtj gyr`)rget_temp_table_namesrrrrcryrrrs r;test_get_temp_table_namesz1ComponentReflectionTest.test_get_temp_table_namess9z"446 F# $6<<.'A&BCr=cft|}|j}tt|dgyr)rget_temp_view_namesrrr(s r;test_get_temp_view_namesz0ComponentReflectionTest.test_get_temp_view_namess/z"335 F# $|n5r=c&|j|yr)_test_get_commentsryrs r;test_get_commentsz)ComponentReflectionTest.test_get_commentss  +r=cX|j|tjjyr)r.rrrQr/s r;test_get_comments_with_schemaz5ComponentReflectionTest.test_get_comments_with_schema"s  GNN,F,FGr=ct|}|j|}t|jd|||dft|jd|||dft|jd|||df|jj j }t|j|||||fy)NrMrLr,)rrrrrrVrh)ryrrNrexpno_csts r;r.z*ComponentReflectionTest._test_get_comments'sz"v.  " ">& " A ( )  " "76 " : ! "  " ">& " A ( ) ++00  " "6& " 9  ! r=)FFzuse_views,use_schemac|rtj}nd}|jj|jj}}|rgd}nddg}t |}t |||fD]\} } |} |j| | } tt| dkDt| t| jD]\} }t|j| | d| | dj}|j}t!|t"j$j&r |j}t)j*dr2|t,j.t,j0fvrt,j.}ttt3|j4j7|j4j7t,j8t,j:t,j0t,j.t,j<t,j>t,j@gdkD|jd |jd | | dd |d |jBr| | d J y) Nrrrr,rErMrrhrrwrz), rr)"rrQrr,rErziprr'len enumeratecolumnsrrh __class__rrrkr TypeEnginerrz sql_typesDateDateTimery__mro__ intersectionrNumericTimer_BinaryrI)ryr use_viewsrrNr, addressesrrrqtable schema_namerir~ctype ctype_defs r;rz(ComponentReflectionTest.test_get_columns?s ''FF KK--t{{/J/Jy JK"$56Kz"!$[5)2D!E J K##J{#CD CIM3t9 -$EMM23CHHd1gfo.Q11HH i)<)<= ) 3 3I??8,NN&&?2!*I EMM*%i&7&78% ) 1 1 ) 1 1 ) 2 2 ) ) ) 0 0 ) 1 1 "xx476?EC#*79-555Q3"Fr=c|j}|j|}t|t|}|j ||dy)NrF)strict_constraints)rerrrassert_tables_equal)ryrrqrrreflected_user_tmps r;test_reflect_table_temp_tablez5ComponentReflectionTest.test_reflect_table_temp_tablesO))+ ;;z*"  *    (U ! r=c.|j}|j|}t|}|j|}t t |dkDt |t |jD]!\}}t|j||d#y)Nrrh) rerrrr'r9r:r;rrh)ryrrqrrrrrJr~s r;test_get_temp_table_columnsz3ComponentReflectionTest.test_get_temp_table_columnss}))+ ;;z*z" +D A s4y) 0 01FAs $q'&/ *2r=ct|}|jd}t|Dcgc]}|d c}gdycc}w)Nrrh)rGrhr)rrr)ryrrrr~s r;test_get_temp_view_columnsz2ComponentReflectionTest.test_get_temp_view_columnss?z" - D )DSS[D )+@A )s =)Fc,|rtjj}nd}|jj|jj }}t |}|j|}|j|j|}|j|g|||jfg|j|j|j|} |||jfd} t| d| tjjj5t| ddddd|jj j} |j|j| |g||| fg|jy#1swY_xYw)NrMrrhrJ)rrrQrr,rErrrrh _check_listrrrOrfail_ifrV) ryrrrNr,rGrr4 users_cons addr_consexp_colsr5s r;rz.ComponentReflectionTest.test_get_pk_constraintsf ^^//FF;;,,dkk.I.Iyz"ll&l)++EJJv+F   L3 345t7M7M **9>>&*I  /01FG I+ ,h7    / / 7 7 9  &!= 1:++00   # #F6 # : ; &&! " #  " " : 9s F  Fc>|rtj}nd}|jj|jj}}t |}|}t jjjr|j|j|}|d} t jjj5t| dddddt| d|t| d|jt| ddgt| d d g|j|j|} | d} t jjj5t!| ddudddt| d|t| d|jt| ddgt| d d g|jj"j} t|j| |gy#1swY;xYw#1swYxYw) NrMrrhr+rrrr-rr3rF)rrQrr,rErrrOrdr4rrhrrXrimplicitly_named_constraintsr'rV) ryrrrNr,rGrexpected_schema users_fkeysfkey1 addr_fkeysr5s r;rz-ComponentReflectionTest.test_get_foreign_keyss ''FF KK--t{{/J/Jyz"     9 9 A A// 6/JKNE!!33;;=E&M<0> '(/ : &' 4 ()I; 7 +,/?.@ A**9>>&*I 1     : : B B D E&M- .E E# $o6 E" #UZZ0 E$ % {3 E' (+;*<=++00 D ! !& ! 8"=+>=E Ds=H'HHHch|jd|jjzdtjj zdtjj z\}}}t |}|j|j}tt|d|d}t|dtjj t|d|jt|dd gt|d d g|j|jtjj }tt|d|d} t| dd|jjfvt| d|jt| dd gt| d d gy)Nz%s.local_tablez%s.remote_tablez%s.remote_table_2rrrrrrGrrYrMr[) rrvrhrrrQrrrhrr9r') ryrrXrZr\r local_fkeysr` remote_fkeysfkey2s r;"test_get_inter_schema_foreign_keysz:ComponentReflectionTest.test_get_inter_schema_foreign_keyss59KK z11EE E  : : : '.."<"< <5 1 \> z"++K,<,<=  C a A E# $gnn&@&@A E" #^%8%89 E$ %v. E' (;-8,,   gnn&@&@-  C q!Q # $""66   E" #[%5%56 E$ %v. E' (:,7r=cx|rtj}nd}t|}|jd|}|j |}|j |||df|j |jjj}|j |j|||||f|j y)Nr,rM) rrQrr rrWrrrVrh)ryrrrNrindexesr4r5s r;r z(ComponentReflectionTest.test_get_indexess ''FFz"""76":f-  S&'*+T-F-F ++00    VF  3  !  % % r=)r_rb)rarcz tname,ixnamect|}|j|}|jd|f}|j|||jt |t |}tt|jdtt|jdj|tt|jdj|y)Nrrr)rr rrWrrrrr9rhr rrHrh)ryrtnameixnamerrhexpected_indexesrs r;test_get_noncol_indexz-ComponentReflectionTest.test_get_noncol_index5sz"""5) ++-tUm< "2D4M4MN %: > C NA DOA  $ $a( DOA  # #V,r=ct|}|j}|j|}|jdd|f}|j |||j y)NT)r)rrer rrWr)ryrrrh reflectedr4s r;&test_get_temp_table_unique_constraintsz>ComponentReflectionTest.test_get_temp_table_unique_constraintsKs]z"##%//5 lll%tTl3 C)B)BCr=cFt|}|j}|j|}|D]}|jddddgddg}tj j jrg|dd<t|Dcgc] }|ddk(s |c}|ycc}w) NrFrrr)rArrhrrrh) rrer rrrOindex_reflects_included_columnsr4r)ryrrrqrhindexpectedrs r;test_get_temp_table_indexesz3ComponentReflectionTest.test_get_temp_table_indexesTsz"))+ "":.C GG%t ,ug} M     ; ; C C-/HQK) * # DGSs6{m'CSG D  Ds  BBc|rtj}nd}tddgddgdddgdddd d gdd d gdd dgdgtjd}t d|t dtjdt d tjdt dtjt d tjdt d tjd|}|D],}|jtj|dd|di.|j|t|}t|jd|tjd} t} t!t#|t#| t%|| D]R\} } | j'dd} | r| j)| t!| j'dddt!| | Tt+}t d|||} | j,Dchc]}|j.}}| j0Dchc](}t3|tjr |j.*c}j5dg}|j7|rJ| r t!| |t!|t|j8j:j.}t!|j||gycc}wcc}w)Nunique_ar)rhr unique_a_b_c)rbr unique_c_a_b)rrryunique_asc_keyascrz i.have.dotsryz i have spacesrrhrtesttblrHr@rMrrr)rrN)rrQroperator itemgetterrrrkrrappend_constraintrrrr ryrr9r8rrrrhrh constraintsr differencerBrrV)ryrWrrrNuniquesrHrrronames_that_duplicate_indexrrefldupereflected_metadatar idx_namesuquq_namesr5s r;r z3ComponentReflectionTest.test_get_unique_constraintses ''FF#cU;'I'I)E5>J&>(3%@  ##F+     3 " & 3 " & 3 # 5"))B- ( 5"))B- (  B  # ###R%7IbjI   Z z"  ' ' & ' A##F+ &)U" CL#i.)gy1JD$88.5D*..t4 D)4 0 dO2&Z  $  *3):):;):#SXX): ; ++ +"b112 GG+  *n% &  ))(333 % *I 6 #% ++00 D ' 'v ' >C< s $K:-K?c|rtj}nd}t|}dD])}|j||}t t |+y)Nr7rM)rrQrrr'bool)ryrrrNrviewrs r;rz0ComponentReflectionTest.test_get_view_definitionsM ''FFz"DD((f(=A DG Er=ct|}tt5|jddddtt5|jddddy#1swY3xYw#1swYyxYw)Nview_does_not_existr,)rrrrrs r;'test_get_view_definition_does_not_existz?ComponentReflectionTest.test_get_view_definition_does_not_existsXz" + ,  $ $%: ;- + ,  $ $W -- ,- , , ,sAA+A(+A4ct|}dD]A\}}|j|}|Dcic]}|d| c}|}|jddrAJycc}w)atest 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-)rEr<)r:r;rhrTN)rrget)ryrrrjcnamerrid_s r;test_autoincrement_colz.ComponentReflectionTest.test_autoincrement_colsjz" LE5 ##E*D)-.A1V9a<.u5C77?D1 11 /s Acttj}|rtjnd}tj j jrY|jd|}tt|t|jd|}tt|tytt5|jd|}dddy#1swYyxYw)Nr,rMrV)rrr9rQrrOrr4rr'rr7rr)ryrrrNrs r;rz.ComponentReflectionTest.test_get_table_optionssvyy!'1##t    1 1 9 9(((@C JsD) *(()9&(IC JsD) *23,,WV,D433s :CC cttj}tjj j rf|rtjnd}|j|}|j|Dcic]}||f|j||}}t||ytt5|j}dddycc}w#1swYyxYw)NrM)rrr9rrOrr4rQget_multi_table_optionsrrrrr)ryrrrNrrHr4s r;test_multi_get_table_optionsz4ComponentReflectionTest.test_multi_get_table_optionssvyy!    1 1 9 9+5V''4F..f.=C"111@@E!7!7f!7!MM@  SM2322443  43s8C 3CCcfd}|S)Nct }||d||d}|r|}g}tj|vr|jgdtj|vr|jddgtj |vr|jddg|r||d<|r||d<|||||j d } |g} |tjk(r2|j} | jd | j| |tjk(r2|j} | jd | j| t | | fS) NrE)r0r)rLr,does-not-existrrrrNr")rNr0rr"r0r) rrrrrr rrrcopyrappend) rNr0rrsingle_reflect_fn exp_methodrrpr"r4kwsnkwrs r;provide_fixturez>ComponentReflectionTest.get_multi_exp..provide_fixturesK:&D d$5 6 $/BL4'##?$&##%8:J$KL++t3##^5E$FG%8 %1>"VVN3 C $C +++ggi  3z'''ggi 3:&S0 0r=rB)ryrrs ` r; get_multi_expz%ComponentReflectionTest.get_multi_exps, 1\r=c|||||tj|j\}}}|D]0} |j|jdi| } t | |2yNrB)rrrrrr ryrrNr0rrrrr4rpresults r;#test_multi_get_table_options_tablesz;ComponentReflectionTest.test_multi_get_table_options_tablesAsi '      ' '     c3B    1T117B7F  r=c|||||tj|j\}}}|D].} |jt |j di| |0yr)rrrrrget_multi_table_comment) ryrrNr0rrrrr4rps r;test_get_multi_table_commentz4ComponentReflectionTest.test_get_multi_table_commentSse '      ' '     c3B     ,,,2r2C 8r=c dtfd}t|tr6t|j Dcic]\}}|||c}}||yt|Dcgc] }|| c}||ycc}}wcc}w)NrcLtjdd|jS)Nz['\" ]r*)resubr)rs r;_cleanz:ComponentReflectionTest._check_expressions.._cleanes66)R.446 6r=)rrr7rr)ryrr4err_msgrers r;_check_expressionsz*ComponentReflectionTest._check_expressionsdsn 7 7 c4 &,,.9.$!QA.93 H F+FqF+S' ::+s A3 A9cT|t|||ytt|t||t||D]j\}}t|t|zD]K}||vs ||vs ||vs|d|d|}|dvr|j |||||9t|||||Mly)Nz - )rr)rr9r8ryr) ryrr4req_keysmsgrrrrs r;rWz#ComponentReflectionTest._check_listms   S ! F SXs +FC(1Q#a&AH}aAF%(EQCs1#"6 AA 33AaD!A$H!adG4 ))r=ctt|jt|j|D](}||||}}|r|g|g}}|j||||*yr)rrykeysrW)ryrr4r make_listsrrrs r;_check_table_dictz)ComponentReflectionTest._check_table_dict{s` C CHHJ0A!9c!fqAsQC1   Q8Q / r=c|||||tj|j\}}}|D]A} |j|jdi| } |j | ||j Cyr)rrrrget_multi_columnsrrrs r;test_get_multi_columnsz.ComponentReflectionTest.test_get_multi_columnssw'      ! !     c3B    +T++1b1F  " "630J0J Kr=c|||||tj|j\}}}|D]C} |j|jdi| } |j | ||j dEy)NT)rrB)rrrrget_multi_pk_constraintrrrs r;test_get_multi_pk_constraintz4ComponentReflectionTest.test_get_multi_pk_constraints '      ' ' LL  c3B    1T117B7F  " "T33 # r=ctjjjsS||fD]K}|j D]6}t |dkDst d|Ds%|j|8Myy)Nrc3bK|]'}|jddtjfv)yw)rhN)rr(r).0rs r; z7ComponentReflectionTest._adjust_sort..s*,CFaf $)993s-/r})rrOr]r4rr9anysort)ryrrtrobjrs r; _adjust_sortz$ComponentReflectionTest._adjust_sortsk<<DD)::.suQ/D-E'Fr=rB)rrrrget_multi_foreign_keysrrrrs r;test_get_multi_foreign_keysz3ComponentReflectionTest.test_get_multi_foreign_keyss '      & & LL  c3B    0T00626F   F   " "630F0F G r=c|||||tj|j\}}}|D]A} |j|jdi| } |j | ||j Cyr)rr rrget_multi_indexesrrrs r;test_get_multi_indexesz.ComponentReflectionTest.test_get_multi_indexessw '      ! !     c3B    +T++1b1F  " "630I0I Jr=c |||||tj|j\}}}|D]U} |j|jdi| } |j | |d|j | ||jWy)Nct|dS)Nrrrs r;rzKComponentReflectionTest.test_get_multi_unique_constraints..sU1^;L5Mr=rB)rr rrget_multi_unique_constraintsrrrrs r;!test_get_multi_unique_constraintsz9ComponentReflectionTest.test_get_multi_unique_constraintss '      , , LL  c3B    6T66<.s U1Y<5Hr=rB)rrrrget_multi_check_constraintsrrrrs r; test_get_multi_check_constraintsz8ComponentReflectionTest.test_get_multi_check_constraintss '      + + LL  c3B    5T55;;F   fc+H I  " "630F0F G r=rrrrr r rrmethodct|}t||}tt5|ddddy#1swYyxYw)Ntable_does_not_exists)rgetattrrr)ryrrrrs r;test_not_existing_tablez/ComponentReflectionTest.test_not_existing_tables80z"tV$ + , ( )- , ,s 9Ac Htjfd}tjj td|5t t d5t|jtdtdddddddy#1swYxYw#1swYyxYw)NcT|jdi}td|d<|i|S)N unreflectableerr)N some_table) setdefaultr)rrurmcs r;patchedz;ComponentReflectionTest.test_unreflectable..patched s1or2B'>u'EB# $q;A; r=rrr) rrr(patchobjectrrr reflect_tablerr)ryrrrs @r;test_unreflectablez*ComponentReflectionTest.test_unreflectable sx  ( (  ZZ  y*=w G&'>F #11, 3TGH GFFH Gs#B .B ;B B BB!rct}|rtjnd}|j|||dt |}|j |}|r)||j |z } ||j|z }|r|Dcgc] }|d| }}tt|jt|y#t$rYJwxYwcc}w)NF)rNr resolve_fksr)) rrrQreflectrrr#r$rrrr) ryrrrmrNrrrs r; test_metadataz%ComponentReflectionTest.test_metadata* s J'1##t *V5e Lz"%%f-  d))&1 1F $::6BB /56v!!ovF6 F188 fVn- '  7s'B:C : CCc Ttd|tdtdtdtdd|j|t |}|j d}t |ddi|jd}|Dcic] }|d |d  }}ddd }t ||ycc}w) Nunicode_commentsunicodeu é試蛇ẟΩrOemojiu ☁️✨u試蛇ẟΩ✨rrhr)rrrrrrrrrr) ryrrWrtcrrvaluer4s r;test_comments_unicodez-ComponentReflectionTest.test_comments_unicode? s   9g ? 7G[ 9$   J'z"  # #$6 7 B)*+ 23267$Q6AiL($7)K@ E38sB%c  td|tdtdd|j|t |}|j d}t |ddi|jdd}t |d|d iddiy) Nrru&🐍🧙🝝🧙‍♂️🧙‍♀️rOu&🎩🁰🝑🤷‍♀️🤷‍♂️rrrhrr)ryrrWrrrs r;test_comments_unicode_fullz2ComponentReflectionTest.test_comments_unicode_fullT s   7G-U V<   J'z"  # #$6 7 BABC   / 0 3 QvY) %1Y'Z[r=rr))NF)mr>r?r@ run_inserts run_deletesrrArXr'rerUrSrrrrrrrrrpropertyrrrrrrrrrrrrrOschema_reflectionrrrr schema_create_deleterrrrrrPr!r%rr)rRrnr,rr0r2r.rrlrQrSrrU!primary_key_constraint_reflectionrrrgrfrr rirjrmrrptemp_table_reflect_indexesrur rrtable_reflectionrrrfixturerrr#rrrrWrrrrrrrrrrrrrrcomment_reflection_full_unicoderrBr=r;r%r%s9 $$K+KNN k-k-Z  OOB4!)Zoo ^^ Boo ^^ "Loo ^^ ^@77 oo ^^ .`// oo ^^ Vp  oo ^^ sj22 oo ^^  CJ(( oo ^^ 8t## ''G(G  ''8(8  '' G( G '' 8( 8 '' ** ;+( ; ''>(>  ''N(NW ((JJK W w''(%,!- !-FW w''(%, - - &&D'D  %% %%6&&6  ((,), (( H)H 0W g&&../ ug&&667      $ $w'7'7'G'G G ( <6 <6B ++  ,   +++,+ ++ ,, %%B&-,B W4))112\ 77 8 :W4))112\ 77$>8$>L 00 "81"8HW4))112\ && ' ,W3/  && ** 22 -3+'  - ++ 22D3,D 00 1 W w''((\ 22TD3TDl %%W4))112\& %%.&. &&2'20W w''((\ E EW4!1!1!9!9:EB 5C 5 __//b ++,  (( 9) 9; 50LL" 778$* 77H8H& &&K'K  22P3P" 11H2H"W g..DDE     > >     > >  ((99: $    9 9 $    8 8  g..AAB+.*/.* W$ =W w%%&.>." (()( 55\6\r=r%ceZdZdZdZej dZej dZdZ dZ dZ ejjdZejjd Zy ) TableNoColumnsTest)reflect_tables_no_columnsTc>td||j|yNr)rrryrrWs r;table_no_columnsz#TableNoColumnsTest.table_no_columnsj s gx J'r=ctd|tj|dtdtj|dtd|j |y)NrrZz*CREATE VIEW empty_v AS SELECT * FROM emptyr[zDROP VIEW IF EXISTS empty_v)rrr]r rrs r;view_no_columnsz"TableNoColumnsTest.view_no_columnso sR gx    < =   mS)F%G  J'r=cntdt|}tt|jgy)Nrrrrrrr)ryrrt2s r;test_reflect_table_no_columnsz0TableNoColumnsTest.test_reflect_table_no_columns s$ 7HJj A DJr=ct|}t|jdg|j}t|dgiy)Nrr)rrrr)ryrrrmultis r;!test_get_columns_table_no_columnsz4TableNoColumnsTest.test_get_columns_table_no_columns s>z" D  W %r*&&( EOR()r=ct}|j|t|jj dgsJyr)rrryrrB)ryrrrs r;"test_reflect_incl_table_no_columnsz5TableNoColumnsTest.test_reflect_incl_table_no_columns s3 J *188}))7)444r=cntdt|}tt|jgy)Nempty_vrr)ryrrrs r;test_reflect_view_no_columnsz/TableNoColumnsTest.test_reflect_view_no_columns s$ 9hj C DJr=ct|}t|jdg|jtj }t|dgiy)Nr)r)Nr)rrrrrr)ryrrrrs r; test_get_columns_view_no_columnsz3TableNoColumnsTest.test_get_columns_view_no_columns sHz" D  Y ',&&JOO&< E%r*+r=N)r>r?r@rrrr rrrrrrOrrr!rBr=r;r r f s1LK __(( __ ( (* 5   ,,r=r c :eZdZdZej ddgdZej dZdZejjdZ ejjejdd d d d Zejjejddd d dZejjdZejj"dZejj&dZdZejj,dZejj,dZejj,dZejd dd ejj4fd d dejj6fid dejj6fidd ejj8fd d dejj:fd dd ejj<fd dZy )ComponentReflectionTestExtraTF)paramsc<|jrtjSyr)paramrrQ)ryrequests r;use_schema_fixturez/ComponentReflectionTestExtra.use_schema_fixture s ==%% %r=c@tjfd}|S)Nc3NKtfjywr)rr)rrrWr(s r;goz:ComponentReflectionTestExtra.inspect_for_table..go s%$gj&99 9    +s"%) contextlibcontextmanager)ryrWrr(r+s ``` r;inspect_for_tablez.ComponentReflectionTestExtra.inspect_for_table s"  " " , # ,  r=c d}t|Dcgc]}|d||ddc}d}t|d}t||ycc}w)Ncdjtjd|jtjS)N zand|\d|=|a|b|c|or|<|>)joinrfindallrI)rs r; normalizez5ComponentReflectionTestExtra.ck_eq..normalize s.88 3W]]_bddK r=rhrrhrc |dSrrBitems r;rz4ComponentReflectionTestExtra.ck_eq.. d9or=r}c |dSrrBr8s r;rz4ComponentReflectionTestExtra.ck_eq.. r:r=)rr)ryrortr5r9s r;ck_eqz"ComponentReflectionTestExtra.ck_eq sj  & %Df)DO2LM% /   .  Ix  sA c |d5\}}td|tdtjd|ddd|j j dgy#1swY-xYw)NrVrJrHrM)rrrkrr<r)ryrWr.rNrs r;#test_check_constraint_no_constraintz@ComponentReflectionTestExtra.test_check_constraint_no_constraint sh / 04GVY  vryy}-  1  + +, 1 AND a < 5rrJrKrMa > 1 and a < 5r6) rrrrkrrrr<r(rryrWr.rArNrros r;test_check_constraint_inlinez9ComponentReflectionTestExtra.test_check_constraint_inline sw '+>FI tWYD9I&&)vvbz* ( 33GF3K  ,7txx0  %( 's A$B11B: my_ck_const MyCkConstc (|d5\}}td|tdttjd||dddj d}|j ||xstjddgy#1swYExYw)NrCrza = 1 OR (a > 2 AND a < 5)rrMza = 1 or a > 2 and a < 5r6) rrrrkrrr<r(rrFs r; test_check_constraint_standalonez=ComponentReflectionTestExtra.test_check_constraint_standalone sw '+>FI sGI&""0 (33GF3K  ,7txx9  ( 's ;BBcz|d5\}}td|tdtdtdttjdtdttjdd td ttd t d tj d d tjdd tj d d | dddjd}|j|dddd ddtjddgy#1swYIxYw)NrCrGTrHrrDryzb > 1 AND b < 5r?rrrJrKsome_uqzc > 1 AND c < 5cc1 some_c_uqrMzc > 1 and c < 5r6zb > 1 and b < 5rE) rrrrkrrrrr<r(r)ryrWr.rNrros r;test_check_constraint_mixedz8ComponentReflectionTestExtra.test_check_constraint_mixed s w '+>FI tWYD9sGIr'9'9:K'LMI&&'8{K sGI&vvbz*##F;""#45A##Ck: (&33GF3K  +<=$1BC.?@  +( 's C D11D:c . td|tdtdtdtdtdtd}tdt j |j j|j jt j |j jd tdt j|j j td |j j|jt}d dgd id g}fd }||d Gddt}G fddt}tjj j"rdgd|dd|dgd d} || |j%d | ddg|d dgd d} || |j'| t)|j+d|t-} td| } nGt/d5t)|j+d|t-} td| } ddd|j1 |j2j4y#1swY1xYw)Nrxr@yzt_idxalong 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_longt_idx_2F)rhrrArctjjjr$g|d<jj dgi|d<y|j diy)Nr_includer)rrOrrr4rrhr)entryrs r; completeIndexzYComponentReflectionTestExtra.test_reflect_expression_based_indexes..completeIndexS s\??GG+-'(!((--.h7,'(  !2B7r=rceZdZdZy)[ComponentReflectionTestExtra.test_reflect_expression_based_indexes..lower_index_strcB|j}d|vxr d|vxsd|vS)NrrRrSr)ryrols r;rzbComponentReflectionTestExtra.test_reflect_expression_based_indexes..lower_index_str.__eq___ s)[[]"}A#)*@sbyAr=NrrBr=r;lower_index_strr]^ s Br=raceZdZfdZy)^ComponentReflectionTestExtra.test_reflect_expression_based_indexes..coalesce_index_strc4d|jvxr|vS)Ncoalescer_)ryrlong_strs r;rzeComponentReflectionTestExtra.test_reflect_expression_based_indexes..coalesce_index_str.__eq__e s!U[[]2Hx57HHr=Nr)rfsr;coalesce_index_strrcd s  Ir=rg)NrTNzlower(x)zlower(y))rhrrrAz coalesce(x, 'z')rz>Skipped unsupported reflection of expression-based index t_idx)rrrr!rrrrRrTrSrerrrrrO reflect_indexes_with_expressionsr4insertrrr rr !compare_table_index_with_expectedrrh)ryrWrrrrtr[rarg expr_indexexpr_index_longrrrfs ` @r;%test_reflect_expression_based_indexeszBComponentReflectionTestExtra.test_reflect_expression_based_indexes7 s?    3r # 3r # 3r #   gtzz!##%%(!##%%ACCEE1BC' lDMM!##%%:; iJ'z""!$#%    8 hqk" Bc B  I I    < < D D 1#J/#J/    J * % OOAz *%!%&xj'CD  O / * OOO ,   %x 0BsBj9B D$$S)84Z3*=  .. *++00 s '4J  Jc td|tdtdtdtd}td|jj }dg|j |jjd<|j|t|}|jd}t|ddgdgdtjdgt|d d d |jjzdgtdt| }tt!|j"d j |jjddgy) NrrRr@rSrUincludeF)rhrrrArrrz %s_includer)rrrr!rrRrrrhrrr rr(rrrrh)ryrWrrrrr rs r;test_reflect_covering_indexz8ComponentReflectionTestExtra.test_reflect_covering_index sE    3r # 3r #   GQSSUU#BEJ--223I>J'z"&&s+  $%(E(+u#'+xx    N, -z00555 E  3 * =  Q  / / 0A0A0F0F G E  r=c td|gt|Dcgc]\}}td|z|c}}}|j|t |j dDcgc]}|d c}Scc}}wcc}w)Nrzt%dr)rr:rrrr)ryrrWrrJtype_rrs r;_type_round_tripz-ComponentReflectionTestExtra._type_round_trip s    8A7G H7G81efUQY&7G H  #*:#6#B#B3#GH#Ga& #GHH IIs A3 $ A9c|j||tjddD]J}t|tjsJt |j dt |j dLy)Nr/)rsr>rCrr precisionscaleryrrWtyps r;test_numeric_reflectionz4ComponentReflectionTestExtra.test_numeric_reflection s_(( )"3"3B": Cc9#4#45 55  r "  1   r=c|j||tjdd}t|tjsJt |j dy)N4r)rsr>rrrlengthrxs r;test_varchar_reflectionz4ComponentReflectionTestExtra.test_varchar_reflection sR## )"2"22"6  #y//000 CJJr=c td|tdtdtdtd}|j|t t |j dDcic] }|d|d c}ddd ycc}w) NrrTr0ryFrhr1)rry)rrrrrrr)ryrrWrr~s r;test_nullable_reflectionz5ComponentReflectionTestExtra.test_nullable_reflection s    3$ / 3% 0    #:.::3? ?CF S_,? U #   s!A=CASCADEzSET NULLz NO ACTIONRESTRICTzexpected,ondelete,onupdatec i}|r||d<|r||d<||}td|tdtddtd|tdtdtd ttd d td t ddtd|tdtdtdt ddtdtt j dgdgfddi|d|j|t|}|jddd}t|D cic]} || s | || c} i|jddd}t||ycc} w)NondeleteonupdaterRrGTrHrrHx_idzx.idxidrtest userrhrKFr0tidztable.idmyfkrr1) rrrrrrkrrrrr) ryrrWrtrrr1roptsrs r;test_get_foreign_key_optionsz9ComponentReflectionTestExtra.test_get_foreign_key_options stT "*GJ  "*GJ   H   4d 3      4d 3 67JvE$B C 66": &      4d 3 66": 6 5' "  # #* ,2 6=   J'z"$$W-a0;  1AaQQZ 126$$V,Q/ : D( 2s  E'E) r>r?r@rrr r(r.r<rOrr>"inline_check_constraint_reflectionrrGrKrPindexes_with_expressionsrmrrrprsrrzr~r1foreign_key_constraint_option_reflection_ondelete1foreign_key_constraint_option_reflection_onupdate1fk_constraint_option_reflection_ondelete_noaction1fk_constraint_option_reflection_onupdate_restrict1fk_constraint_option_reflection_ondelete_restrictrrBr=r;r#r# sKW__T5M*+ W__!. 11  2   88WZ0A 9 @ 11W{D3D 2 4 88 9 > ..X /X t 55( 6( TI &&' &&' && ' W       N N         N N         N N         N N         N N         N N  .K&N3O&N3r=r#c0eZdZdZdZedZdZdZy)NormalizedNameTest)denormalized_namesTc ttdd|tdtdttdd|tdtdtdt dy) NrTrrGrHrt1idzt1.id)rr"rrrrVs r;rXz NormalizedNameTest.define_tablesK sU D )  4d 3  D )  4d 3 6:g. /  r=ct}ttdd|tj}|j d}|j jj|j jsJt}|jtjd|j dj jj|j dj jsJy)NrTrrrc&|jdvS)Nrrr_)rhrs r;rzINormalizedNameTest.test_reflect_lowercase_forced_tables..c sDJJLL,Hr=)only) rrr"rr9rrrrrGr)ryrt2_reft1_refm3s r;$test_reflect_lowercase_forced_tablesz7NormalizedNameTest.test_reflect_lowercase_forced_tablesY s Z D )2VYY 4xx}}'' 444 Z IIH  yy  %%0041B1B1E1EFFFr=cRttjjDcgc]}|j dvr|}}t |dj |dj t |dj |dj ycc}w)Nrrr)rrr9rrrupper)ryr tablenamess r;r!z'NormalizedNameTest.test_get_table_namesg sVYY'779 9wwyL( 9  JqM   !:a=#6#6#89 JqM   !:a=#6#6#89 sB$N) r>r?r@rrrArXrr!rBr=r;rrG s)*LK     G:r=rc\eZdZdZdZdZdZejjdZ y)ComputedReflectionTestcttj}|jd}|Dcic]}|d| }}t d|ddvt |dddt |dddycc}w)Ncomputed_default_tablerh42 with_defaultrnormal computed_col)rrr9rr'r )ryrrrcol_datas r;!test_computed_col_default_not_setz8ComputedReflectionTest.test_computed_col_default_not_sets svyy! 89*./$QAfIqL$/0;;< HX y )40 H^ $Y /60s A6cTttj}|jd}|Dcic]}|d| }}dD]}t d||v|d}t d|vt d|dvt |j |dddt d|dvtjjjtjjjr5t |ddtjjjyycc}w) Nrrh)rGrrcomputedrr normal+42 persisted) rrr9rr'rr5rrO"computed_columns_reflect_persistedr4"computed_columns_default_persisted)ryrrrrJrcompDatas r; test_get_column_returns_computedz7ComputedReflectionTest.test_get_column_returns_computed| svyy! 89&*+d& 1 d+3C Jd3i/ 04' h&' Xj112 DNN8J/ : ;[I 8J/ /    ? ? G G     > > F F $[1  CCKK  G,s D%ctd||v||d}t|j|d|tjj j rtd|vt|d|yy)Nrrr)r'rr5rrOrr4r )ryrJcolumnrrrs r; check_columnz#ComputedReflectionTest.check_column sp d6l*+< + DNN8I. /9    > > F F K8+ , %y 1 Gr=cttj}|jd}|Dcic]}|d| }}|j |ddt j jjt j jjr|j |dddt j jjr|j |dd d yycc}w) Ncomputed_column_tablerhcomputed_no_flagrcomputed_virtualznormal+2Fcomputed_storedz normal-42T) rrr9rrrrOrr4computed_columns_virtualcomputed_columns_storedryrrrrJs r;!test_get_column_returns_persistedz8ComputedReflectionTest.test_get_column_returns_persisted svyy! 78&*+d& 1 d+        ? ? G G     4 4 < <   "      3 3 ; ;   !   <,s C&cttj}|jdtj}|Dcic]}|d| }}|j |ddt jjjt jjjr|j |dddt jjjr|j |d d d yycc}w) NrrMrhrz normal/42rznormal/2Frz normal*42T) rrr9rrQrrrOrr4rrrs r;-test_get_column_returns_persisted_with_schemazDComputedReflectionTest.test_get_column_returns_persisted_with_schema svyy! #F,>,>  '++d& 1 d+        ? ? G G     4 4 < <   "      3 3 ; ;   !   <,s C6N) r>r?r@rrrrrrOrPrrBr=r;rrr s67*26 r=rcpeZdZdxZZdZdZedZdZ dZ e jjdZy)IdentityReflectionTestNT)identity_columnsrctd|tdttdtttd|tdttdddd d dd tj j jrGtd|tdttdttdd tjyy)Nrrid1rrTrrrSalwaysstart incrementminvaluemaxvaluecyclecacherH)rrrM) rrrrrrOrPr4rrQrVs r;rXz$IdentityReflectionTest.define_tables s   8W % 5'8: .       "    # # + + x)ugxt2'FG))   ,r=ctjjjrd}t |D]}||vs|j ||rlt t|t||D]H}|dk(rt||||k|dvrt||||k\6t |||||Jyt ||yt |d|dt |d|dy)Nrr>rrrr) rrOidentity_columns_standardr4rrrr9r')ryrr4approx common_keysrs r;checkzIdentityReflectionTest.check s    5 5 = =K%[K'IIaL!CJC)AJaCF 2333aCF 23E!Hc!fa0 E3 gG - k"C $4 5r=c .ttj}|jd|jdz}|D]}|ddk(rt d|v|ddk(rVd|vrt |dt |ddt d|v|j|dtd d d d d d d d w|ddk(sd|vrt |dt |ddt d|v|j|dtd ddddd d d y)NrrrhridentityrrrFrrTrrrrrrSr) rrr9rr&r'rrr7ryrrr~s r;test_reflect_identityz,IdentityReflectionTest.test_reflect_identity sAvyy!%(8(8(>>C6{h&s*+V%"c)C01C ND) c)*  O$"#!"!+#  V%"c)C01C ND) c)*  O#"#!#!#"! 5r=c nttj}|jdtj}|D]v}|ddk(rt d|v|ddk(s"d|vrt |dt|ddt d|v|j|dtd d d d d d d d xy)NrrMrhrrrrrTrHrrFrr) rrr9rrQr&r'rrr7rs r;test_reflect_identity_schemaz3IdentityReflectionTest.test_reflect_identity_schemaD svyy!V-?-?@C6{h&s*+V%"c)C01C ND) c)*  O# "#!"!+#  r=)r>r?r@rrrrrArXrrrrOrPrrBr=r;rr sT $$K+K;LB6:*X r=rceZdZdZedZejjdZ ejjdZ y)CompositeKeyReflectionTestTc2td|tdttdttdtjdt j dddddd }td |tdtd td ttd ttdtjdt jgd|jj|jj|jjgddd y)Ntb1rGattrrhrHpk_tb1rTr9tb2rHpidpattrpnamerrrfk_tb1_name_id_attr) rrrr>rmrkrrrrhrGr)r:rWrs r;rXz(CompositeKeyReflectionTest.define_tablesc s   4 ! 67 # 69,,R0 1  # #FD&x H      4d 3 5' " 7G $ 7I--b1 2  # #)SUUXXsuuzz2*   r=ct|}|j|jjj}t |j dgdy)NrrhrGr)rrrrrhrr)ryrrrIs r;test_pk_column_orderz/CompositeKeyReflectionTest.test_pk_column_order sAz",,T[[__-A-AB  KOO1 24JKr=c t|}|j|jjj}t t |d|d}t |jdgdt |jdgdy)Nrrrrrr)rrrrrhrr9r)ryrr foreign_keysr`s r;test_fk_column_orderz/CompositeKeyReflectionTest.test_fk_column_order snz",,T[[__-A-AB  C q!Q EII( )+AB EII+ ,.GHr=N) r>r?r@rrArXrrOrrrrrBr=r;rr` s]K  6 77L8L  77I8Ir=r) r%r#r rrrDrrrrr)Dr,rrr5rkr*rrrrrr r r provisionr r rNrrrrrrrrrrrrr>rrrrexcrrr r! sql.elementsr" sql.schemar#r$r%r&r'r(rWr, TablesTestr+rDrTestBaserrr#r%r r#rComputedReflectionFixtureTestrrr__all__rBr=r;rs $+/" !#*'&&%% h11  S:*S:lJ 8&&J Z91x'8'891xT0X00T0n1