U kf@sddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd l mZdd l mZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm 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'lm/Z/d(\Z0Z1Gd)d*d*e j2Z3Gd+d,d,e3Z4Gd-d.d.e j2Z5Gd/d0d0e j6Z7Gd1d2d2e j2Z8d3d4Z9Gd5d6d6e,e3Z:Gd7d8d8e j6Z;Gd9d:d:e+e j6Zd>e j>Z?Gd?d@d@e j2Z@GdAdBdBe j2ZAdCZBdS)DN)config)engines)eq_) expect_raises)expect_raises_message)expect_warnings)fixtures)is_)get_temp_table_name)temp_table_keyword_argsColumn)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)mock)NNc@seZdZeddZdS)OneConnectionTablesTestcCs6tjjjr,ddlm}tjt|j dddStj SdS)Nr)poolclass)Z poolclassscope)options) r requirementsZindependent_connectionsenabled sqlalchemyr*rtesting_enginedictZ StaticPooldb)clsr*r5X/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/testing/suite/test_reflection.py setup_bind7s    z"OneConnectionTablesTest.setup_bindN)__name__ __module__ __qualname__ classmethodr7r5r5r5r6r)6sr)c@seZdZdZeddZeddZeddZedd Zd d Z d d Z e j j ddZe j j ddZe j jddZe j jddZe j je j je j jddZe j je j j ddZdS) HasTableTestTcCs~td|tdtddtdtdtjjjrTtd|tdtddtdtdtj dtjj rf| |tjj jrz| |dS) N test_tableidT primary_keydata2 test_table_sschema)rrrrrrequiresschemasr/r test_schemaview_reflection define_viewshas_temp_tabledefine_temp_tablesr4metadatar5r5r6 define_tablesIs$       zHasTableTest.define_tablescCspd}t|dt|t|dtdtjjjrldtjtjf}t|dt|t|dtdtjdS)Nz1CREATE VIEW vv AS SELECT id, data FROM test_table after_create before_dropz DROP VIEW vvz9CREATE VIEW %s.vv AS SELECT id, data FROM %s.test_table_szDROP VIEW %s.vv) rlistenr rrFrGr/rrH)r4rNqueryr5r5r6rJ_s   zHasTableTest.define_viewscCstttjdtjSNZ user_tmp_r rr3identr4r5r5r6temp_table_nameus  zHasTableTest.temp_table_namec Cstttj}|}t||tdtjddtdtdf|}t j j j r|t j j j r|t|dtdtjt|dtd dS) Nr>Tr?namerBrP=create temporary view user_tmp_v as select * from user_tmp_%srQdrop view user_tmp_v)r rr3rXrrsaINTVARCHARrrFrIr/temporary_viewsrrRr rVr4rNkw table_nameuser_tmpr5r5r6rL{s0 zHasTableTest.define_temp_tablesc CsVtjB}ttjj|dttjj|dttjj|dW5QRXdS)Nr=rCnonexistent_table)rr3beginr'dialect has_tabler&selfconnr5r5r6test_has_tables zHasTableTest.test_has_tablec Csttj}t|dtd|tdt}t|d| tjz(t|d| t|dW5| tjXdS)Nr=Z new_tablecol) rrr3r'rgrrrr&createdrop clear_cache)rirNinspntr5r5r6test_has_table_caches  z!HasTableTest.test_has_table_cachec CshtjT}ttjjj|dtjdttjjj|dtjdttjjj|dtjdW5QRXdS)Nr=rDrCrd)rr3rer&rfrgrHr'rhr5r5r6test_has_table_schemas, z"HasTableTest.test_has_table_schemac Cs2tj}ttjjj|dddW5QRXdS)Nr=Znonexistent_schemarD)rr3rer&rfrgrhr5r5r6!test_has_table_nonexistent_schemas z.HasTableTest.test_has_table_nonexistent_schemacCst|}t|ddSNZvvrr'rgri connectionrpr5r5r6test_has_table_viewsz HasTableTest.test_has_table_viewcCs"t|}|}t||dSN)rrXr'rg)rirxrprXr5r5r6test_has_table_temp_tablesz&HasTableTest.test_has_table_temp_tablecCst|}t|ddSN user_tmp_vrvrwr5r5r6test_has_table_temp_viewsz%HasTableTest.test_has_table_temp_viewcCst|}t|dtjdSru)rr'rgrrHrwr5r5r6test_has_table_view_schemasz'HasTableTest.test_has_table_view_schemaN)r8r9r: __backend__r;rOrJrXrLrkrrrrFrGrsrtviewsryrKr{rIr_r~rr5r5r5r6r<Fs4         r<c@sTeZdZdZeddZejddddZdd Z ed d Z ej j ed d Z dS) HasIndexTestTc Cstd|tdtddtdtdtdtd}td|jjtjj j r|td|tdtddtdtdt j d }td |jjdS) Nr=r>Tr?rArBdata2my_idxrDmy_idx_s) rrrrr!crArrFrGr/rrH)r4rNttr5r5r6rOs"      zHasIndexTest.define_tablesrf inspectorkindargnamescs"|dkrfddStjSdS)Nrfcstjjjf||Srz)rr3rf has_index)akrjr5r6z)HasIndexTest._has_index..)rr)rirrjr5rr6 _has_indexs zHasIndexTest._has_indexc Cs|||}|ddst|ddr(t|ddr6t|ddrDt|ddrRt|ddr`ttd|jjjj}td|td t tdd }| || |zV|d kr|ddrt|ddrt|j |ddd kst|ddd kstW5| || |XdS) Nr=rrrdZnonexistent_idxZmy_idx_2Z test_table_2Zmy_idx_3foorT)rAssertionErrorr!tablesr=rrrrrrmrn__self__ro)rirrxrNmethidxZtblr5r5r6test_has_indexs2     zHasIndexTest.test_has_indexcCs`|||}|ddtjds t|ddtjdr4t|ddtjdrHt|ddtjdr\tdS)Nr=rrDrrdZnonexistent_idx_s)rrrHr)rirrxrr5r5r6test_has_index_schemas  z"HasIndexTest.test_has_index_schemaN)r8r9r:rr;rOr combinationsrrrrFrGrr5r5r5r6rs  rc @sTeZdZdZdZejdddddded dd gejd d d dddddZdS) BizarroCharacterFKResolutionTestztests for #10275T)r>)z(3))zcol%p)z[brack] columnnamer use_compositeF)plain)z(2))z per % cent)z [brackets] tablenamec Cs t||t|tddddd}|r4|tdtdd|r~td|tdtddtdttd ttdd g|jj|jjgddn*td|tdtddtdt |jjdd| |t }td||d }|j |} |jj | jd st|r|jj| jd stdS) Nr>T)keyr@ test_needs_fkid2r?otherrefref2 autoload_withr)rrr append_columnr\ForeignKeyConstraintrr>rr create_allrrr referencesrr) rirxrNrrrrm2o2t1r5r5r6 test_fk_ref-s@     z,BizarroCharacterFKResolutionTest.test_fk_refN) r8r9r:__doc__rrrZ variationrr5r5r5r6r(s$rc@seZdZdZdZeddZddZeddZee j j d d Z ed d Z ed dZeddZeddZee j jddZee j jddZee j jddZdS)QuotedNameArgumentTestonceTcCstd|tdttdtdtdtdtdttjdddtd dtjdd dtjdgd gd dtj d ddddd t j j j rtd|tdttdtdtdtdtdttjdddtddtjdddtjdgd gddtj d ddddd td|tdtddtdtddt j jj rt j j j r>ddg}ndg}|D]f}dtjjjd|tjjj|f}t|dt|t|dtd tjjjd|qHdS)!N quote ' oner>rYrBrAZ related_idzpk quote ' onerYzix 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 commentrelatedr?rz"CREATE VIEW %s AS SELECT * FROM %sview %srPrQz DROP VIEW %s)rrrrr\PrimaryKeyConstraintr!UniqueConstraintrCheckConstraintrrFsymbol_names_w_double_quoter/view_column_reflectionrr3rfZidentifier_preparerquoterrRr )r4rNnamesrYrSr5r5r6rOgs                z$QuotedNameArgumentTest.define_tablescCstddtjjf|S)N)rr)rrrFr)fnr5r5r6quote_fixturess  z%QuotedNameArgumentTest.quote_fixturesc CsPttj}tjjjr.||}tt |t nt t ||}W5QRXdSrz) rrr3rrFreflect_table_optionsr/get_table_optionsr' isinstancer2rNotImplementedError)rirYrpresr5r5r6test_get_table_optionss     z-QuotedNameArgumentTest.test_get_table_optionscCs ttj}|d|stdS)Nr)rrr3get_view_definitionrrirYrpr5r5r6test_get_view_definitions z/QuotedNameArgumentTest.test_get_view_definitioncCsttj}||stdSrz)rrr3 get_columnsrrr5r5r6test_get_columnss z'QuotedNameArgumentTest.test_get_columnscCsttj}||stdSrz)rrr3get_pk_constraintrrr5r5r6test_get_pk_constraints z-QuotedNameArgumentTest.test_get_pk_constraintcCsttj}||stdSrz)rrr3get_foreign_keysrrr5r5r6test_get_foreign_keyss z,QuotedNameArgumentTest.test_get_foreign_keyscCsttj}||stdSrz)rrr3 get_indexesrrr5r5r6test_get_indexess z'QuotedNameArgumentTest.test_get_indexescCsttj}||stdSrz)rrr3get_unique_constraintsrrr5r5r6test_get_unique_constraintss z2QuotedNameArgumentTest.test_get_unique_constraintscCsttj}||stdSrz)rrr3get_table_commentrrr5r5r6test_get_table_comments z-QuotedNameArgumentTest.test_get_table_commentcCsttj}||stdSrz)rrr3get_check_constraintsrrr5r5r6test_get_check_constraintss z1QuotedNameArgumentTest.test_get_check_constraintsN)r8r9r:Zrun_create_tablesrr;rOrrrrFrrrrrrunique_constraint_reflectionrcomment_reflectionrcheck_constraint_reflectionrr5r5r5r6rcs6 R        rc Cstjdddtjjfdd}tjtjtjtjdd}tjtj tj tj tjtj tj tj Btj tj Bdd}tjddd d}|||||S) NcSstjSrz)rrHr5r5r5r6rrz$_multi_combination..rErr,rTF use_filter) rrrFrGrDEFAULT TEMPORARYANYrTABLEVIEWMATERIALIZED_VIEWZANY_VIEW)rrEr,r filter_namesr5r5r6_multi_combinations2   rc @s$eZdZdZZdZeddZeddZeddZ ed d Z ed d Z d dZ ddZ ddZdejejdfddZdejejdfddZdejejdfddZeddZdejejdfddZeddZdejejdfdd Zed!d"Zdejejdfd#d$Zed%d&Zdejejdd'fd(d)Zed*d+Zdejejdfd,d-Zed.d/Z e!j"j#d0d1Z$e!j"j#d2d3Z%e!j"j#d4d5Z&e!j"j#d6d7Z'e!j"j#e!j"j(d8d9Z)e!j"j#d:d;Z*e!j"j#de!j"j-fd?d@e!j,de!j"j.fd'dAd@dBdCZ/e!j,de!j"j.fd'dAd@dDdEZ0e!j"j1dFdGZ2e!j"j3e!j"j4dHdIZ5e!j"j6dJdKZ7e!j"j6e!j"j.dLdMZ8ddNdOZ9e!j,dPd'de!j"j.fdd'e!j"j3fdde!j"j.e!j"j3fdQd@dRdSZ:e!j"j;dTdUZe!j"j4dXdYZ?e!j,dZde!j"j.fdAd@e!j"j@d[d\ZAe!j,dZde!j"j.fdAd@e!j"j-d]d^ZBe!j"jCe!j"j.d_d`ZDe!j,dZde!j"j.fdAd@e!j"jEdadbZFe!j,dcddded@e!j"jEe!j"jGe!j"jHdfdgZIe!j"j;e!j"jJdhdiZKe!j"jLdjdkZMe!j,de!j"j.fdZdAd@e!j"jJdldmZNe!j"j3e!j,dZde!j"j.fdAd@dndoZOe!j"j3dpdqZPe!j"jQdrdsZRe!j,de!j"j.fdZdAd@dtduZSe!,de!j"j.fd'dvdwZTe!jUdxdyZVe!j"jWeXdzd{ZYe!j"j6eXd|d}ZZd~dZ[dddZ\dddZ]eXddZ^e!j"j@eXddZ_ddZ`e!j"j-eXddZae!j"jEeXddZbe!j"jJeXddZce!j"jdeXddZee!j,de!j"jWfdde!j"j@fde!j"j-fde!j"jEfde!j"jJfde!j"jdfde!j"j6fdd@ ddZfddZge!j,dd'dAd@e!j,de!j"jhfd'dd@ddZie!j"j6ddZje!j"jkddZldS)ComponentReflectionTestNTcCs*||dtjjjr&||tjjdSrz)define_reflected_tablesrrFrGr/rrHrMr5r5r6rOs  z%ComponentReflectionTest.define_tablescCs|r|d}nd}tjjjr0td|ddf}nd}td|tdtjd d td t d d dtdt d dtdtj f|tj ddddt d|d d }td|tdtj d d tdtj td|dddtdtj td|tdt dd d tj d!d"dtjddd#d$d|d d td%|tdtj td&tj t|jjtd't d(d d)tjdd*d+d|d dtd,|td-tj d d.d/tdt d(d0d1td2t d(d3d1td4t d5d6d1|d7d8td9|tdt d(|d:d8tjjjr|dkr4td;|td-tj d d tdt d(tdnntd?|td-tj d d td@tdAtjjjtdt d(|d dtdB|td-tj d d tdt d(|d dtjjjrhtdC|jj|jjd d tdD|jj|jj|jj|shtdE|tdFt d d dG}tdH|td-tj d d tdFt d d dG}tjjjrhtjjjrhtdI|jjtdJ|jjtjj jr|!|||stjj"jr|#|dS)KN.z%susers.user_id user_id_fkrr5usersuser_idTr?test1Fnullabletest2parent_user_id test2 > 0zz_test2_gt_zerousers check constraintrYr test2 <= 1000rEr dingalings dingaling_id address_idz%semail_addresses.address_idzz_email_add_id_fg di fk commentid_userrA)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_testr> id comment)r@rdata % commentrd2)Comment types type speedily ' " \ '' Fun!d3*Comment with escapesthe test % ' " \ table comment)rErno_constraints"no constraints has escaped comment local_table remote_idz%s.remote_table_2.id)rrE 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)$rrFself_referential_foreign_keysr/rrrr\r]ZCHARFloatrrrrrrrcross_schema_fk_reflectionrrHr3rfdefault_schema_nameindex_reflectionr!rrindexes_with_ascdescreflect_indexes_with_ascdescr!descrrJtemp_table_reflectionrL)r4rNrEZ schema_prefixZparent_id_argsrr r"r5r5r6r!sJ              z/ComponentReflectionTest.define_reflected_tablescCstttjdtjSrTrUrWr5r5r6rXs  z'ComponentReflectionTest.temp_table_namec Cstttj}|}t||tdtjddtdtdtdtjtj ddtj dt d df|}t j jjrt j jjrt|d td tj t|d td dS)Nr>Tr?rYrBr user_tmp_uq_r user_tmp_ixrPrZrQr[)r rr3rXrrr\r]r^rrVr!rrFrIr/r_rrRr r`r5r5r6rLs6   z*ComponentReflectionTest.define_temp_tablesc Cstjjjrdh}nt}dD]}|}|r6|d|}|d}||krJdnd}d|d|d |}t|d t|||krd } |rtd r|d| } d | d|d} t|d t| t|dtd|d|qdS)Nr)rrrr_vz MATERIALIZED rzCREATE zVIEW z AS SELECT * FROM rP mat_indexoraclez CREATE INDEX z ON z(data)rQzDROP ) rrFmaterialized_viewsr/setrrRr against) r4rNrE materializedrbfullnameZ view_nameprefixrSZ index_namerr5r5r6rJs. z$ComponentReflectionTest.define_viewscCsDi}tj|kr||tj|kr,||tj|kr@|||Srz)rrupdaterr)rirrrr6rr5r5r6 _resolve_kinds      z%ComponentReflectionTest._resolve_kindcCs<tjjjs||ntjjjs8|||dSrz)rrFrr/clearr3r9)rirr6r5r5r6_resolve_viewss     z&ComponentReflectionTest._resolve_viewsc sdd|tjkrdd|tjkr,dddddhtjjddd d |hitjjj s|d dtjj ddgtjj j sd dd gtjj j rtjjj sˆd d |gtjjj s܈d d gfd d |D}|S) NcSsdS)NTr5)_r5r5r6r%rz8ComponentReflectionTest._resolve_names..cSs d|dkSNtmprr5rr5r5r6r'rcSs d|dkSr>r5r@r5r5r6r)rrrrr r"r}cs>i|]6\}}|r|dkrr4|dkr||qS)rr5).0rvrZremovedrEZ scope_filterr5r6 Fs z:ComponentReflectionTest._resolve_names..)rrrrrrHrXrFr'r/addr9r)r-temp_table_namesr_items)rirEr,rvaluesrr5rCr6_resolve_names$sF      z&ComponentReflectionTest._resolve_namesc Cs|dftji}|dftj|dftj|dftji}||||dftj|dftj|dftj|dftj|d ftj|d ftj|d ftj|d ftj|d ftj|dftj||ftji }|||||}|||||}|S)N dingalings_vemail_addresses_vusers_vr}rrrr rrrrr r"r(rr<rXr:rI) rirEr,rrr6rrrr5r5r6 exp_optionsOsF   z#ComponentReflectionTest.exp_optionsc Csddi}|df|i}|df||df||df|i}||||df||df||df||d fdd i|d fdd i|d f||df||df||df||df|||f|i }|||||} ||||| } | S)NtextrJrKrLr}rrrr rrrrrrr r")r<rXr:rI) rirEr,rremptyr6rrrr5r5r6 exp_commentsnsP   z$ComponentReflectionTest.exp_commentsc s$dtjddfddfdd}|dfdd tjd d d d gi}|dfd d tjd ddg|dfdd tjd dtjddtjddg|dfdd tjd ddgi}||||df|ddddddddg|df|dd d d g|df|d ddg|df|ddd d d!d d"d#d d$d%d g|d&fd g|d'f|dd d(g|d)f|dd*d g|d+f|dd g|d,fd-g|d.f|dd-g||f|dddgi }|||||} ||||| } | S)/NFTcSs*||tj|||d}|dkr&|d|S)N)rY autoincrementtypedefaultrromitrR)r(rpop)rYautorTrrrr5r5r6rls z0ComponentReflectionTest.exp_columns..colcsdtjdd|}|f|S)NTF)rWrTrr(r)rYrarlr5r6pksz/ComponentReflectionTest.exp_columns..pkrJrrU)rWrrrrArKrrrLrrrrrr}r>rYrrrrr rrrrrrrrrrrrrr r!r"rM) rirEr,rrrZr6rrrr5rYr6 exp_columnss             'z#ComponentReflectionTest.exp_columnscCs ddddhS)NrYrSrrTr5rir5r5r6_required_column_keyssz-ComponentReflectionTest._required_column_keysc CsNtjdddd}|dd}tjjjr8|df|di}n |df|i}|df||df||d f|i}||||d f|d |d f|d|d f|dddd|df|d|df||df|d|df|d|df|d|df||df|d||f|di } tjjjs*| D]} | ddk r tj| d<q | || ||} | |||| } | S)NrcWst|||dS)N)constrained_columnsrYr)list)rYrcolsr5r5r6rZsz+ComponentReflectionTest.exp_pks..pkrrJrrKrLr}rrrrrr r r r>rrrrr r"rY) r(rrrFZmaterialized_views_reflect_pkr/r<rXreflects_pk_namesrHr:rI) rirEr,rrrZrPr6rrvalrr5r5r6exp_pkss^       zComponentReflectionTest.exp_pkscCsddhS)NrYr^r5r\r5r5r6_required_pk_keys&sz)ComponentReflectionTest._required_pk_keysc sGddd|tjdffdd }|dfgi}|dfg|dfg|dfgi}||||d f|d gd gd d d g|df|dgd gd |dgdgddddg|df|dgd gd g|dfg|dfg|df|dgdgdtjdg|df|dgdgdddg|dfg|dfg|d fg||fgi }tjjj s<||d f tjj j s~| D],} | D] } | d!tjk rXtj| d!<qXqP| ||||} ||||| } | S)"Nc@seZdZddZdS)z+ComponentReflectionTest.exp_fks..ttcSs|dkptjjj|kSrz)rr3rfr(rirr5r5r6__eq__2s z2ComponentReflectionTest.exp_fks..tt.__eq__Nr8r9r:rfr5r5r5r6r1srcs$|||tj|dk r|n||dS)N)r^referred_columnsrYr-referred_schemareferred_tablerrX)r`Zref_colZ ref_table ref_schemarYrrr5r6fk8s z+ComponentReflectionTest.exp_fks..fkrJrKrLr}rrrrrrrrrrrrrr rrrr>r)rkrrr r"rY)r(rr<rrHrXrrFr%r/r;named_constraintsrHr:rI) rirEr,rrrmr6rrvalsrbrr5rlr6exp_fks*s     #   zComponentReflectionTest.exp_fkscCsdddddhS)NrYr^rirjrhr5r\r5r5r6_required_fk_keyss z)ComponentReflectionTest._required_fk_keysc Csddddddd}|dfgi}|dfg|dfg|dfgi}||||rf||df|d d d |d f|d ddd|ddddd |ddddd|df|d tjddd|dtjdd|dddddd|df|dtjd |dtjdd|d fg|d!fg|d"f|d#tjdd|d$f|d%tjdd|d&fg|d'f|d(d)d(d*id+|d,f|d(d-d(d*id+||f|d.d/d |d0d1tjddd2i }tjj j rtjj j s||d'f ||d,f | ||||} ||||| } | S)3NF)rcolumn_sorting duplicatesrmc stjj}tjj}tjj}|r"|jr,|r0|js0dS|t||tjgd} r~| d<|jr~| d| d<} fdd| D| d<|r|| d<| gS) Nr5)r column_namesrYdialect_optionsinclude_columnsrrrt expressionscsg|]}|krdn|qSrzr5rArrrr5r6 szDComponentReflectionTest.exp_indexes..idx..Zduplicates_constraint) rrFZforeign_keys_reflect_as_indexZ#unique_constraints_reflect_as_indexZ*reflect_indexes_with_ascdesc_as_expressionr/r_r(r) rYrrrrsrmr`Zfk_reqZdup_reqZsorting_expressionrorigr5ryr6rs4   z0ComponentReflectionTest.exp_indexes..idxrJrKrLr}rAr1rrrrT)rYrmrrrrr)rYrr)rYrrsrrrrrrrr rrrrrrr r!r#)r,)rYrrr"r$rr/rYr.)rYrsr)r<extendr(rrXrrVrrFr*r/r+r;r:rI) rirEr,rrrr6rrrr5r5r6 exp_indexess  %          5z#ComponentReflectionTest.exp_indexescCs dddhS)NrYrtrr5r\r5r5r6_required_index_keyssz,ComponentReflectionTest._required_index_keysFc Csdddddd}|dfgi}|dfg|dfg|dfgi}||||d f|d d d d d d|df|dtjtjd|dddddd|dfg|dfg|dfg|dfg|dfg|dfg|dfg|dfg||f|dd tjd!i } |r||| S||| ||} ||||| } | SdS)"NF)duplicates_indexis_indexrcWs8tjj}|r|jsdSt|||d}|r2||d<|gS)Nr5)rtrYrr)rrFZ*unique_index_reflect_as_unique_constraintsr/r_)rYrrrr`reqrr5r5r6uc s z+ComponentReflectionTest.exp_ucs..ucrJrKrLr}rrrrT)rYrrrrA)rYrrrrr)rYrrrr rrrrr r"rYr.r)r<r(rrXrrVr:rI) rirEr,rrall_rr6rrrr5r5r6exp_ucssr         zComponentReflectionTest.exp_ucscCsddhS)NrYrtr5r\r5r5r6_required_unique_cst_keysJsz1ComponentReflectionTest._required_unique_cst_keysc sGdddtdfdd }|dfgi}|dfg|dfg|dfgi}||||d f|d tj|d d d dg|df|dddg|dfg|dfg|dfg|dfg|dfg|dfg|dfg|dfg||fgi }|||||} ||||| } | S)Nc@seZdZddZdS)z+ComponentReflectionTest.exp_ccs..ttcSs(|dddddd}||kS)N(r)`)lowerreplace)rirrr5r5r6rfVsz2ComponentReflectionTest.exp_ccs..tt.__eq__Nrgr5r5r5r6rUsrcs|||dS)N)sqltextrYrr5)rOrYrrlr5r6cc_sz+ComponentReflectionTest.exp_ccs..ccrJrKrLr}rrrrrrrz$address_id > 0 and address_id < 1000rrrr rrrrr r")N)strr<r(rrXr:rI) rirEr,rrrr6rrrr5rlr6exp_ccsNs^     zComponentReflectionTest.exp_ccscCsddhS)NrYrr5r\r5r5r6_required_cc_keyssz)ComponentReflectionTest._required_cc_keyscCs t|}ttjj|kdSrz)rr'rrrHget_schema_namesrwr5r5r6test_get_schema_namessz-ComponentReflectionTest.test_get_schema_namescCs,t|}t|tjjt|ddS)Nsa_fake_schema_foo)rr' has_schemarrrHr&rwr5r5r6test_has_schemasz'ComponentReflectionTest.test_has_schemacCs8|jddttjjid}t|}ttjj|kdS)z test #7300rbarZschema_translate_mapN)execution_optionsr#rrrHrr'rrwr5r5r6%test_get_schema_names_w_translate_mapsz=ComponentReflectionTest.test_get_schema_names_w_translate_mapcCsD|jddttjjid}t|}t|tjjt|ddS)Nrrrr) rr#rrrHrr'rr&rwr5r5r6test_has_schema_w_translate_mapsz7ComponentReflectionTest.test_has_schema_w_translate_mapc Cst|}td|kt|d|tdzHtd|kt|d|td|kt|dW5|tdXdS)NZfoo_barzCREATE SCHEMA foo_barzDROP SCHEMA foo_bar)rr&rrexecuter ror'rwr5r5r6test_schema_cachesz)ComponentReflectionTest.test_schema_cachecCs$t}t|t|jds tdS)Nr()rr1rhasattrrfr)rienginer5r5r6test_dialect_initializesz/ComponentReflectionTest.test_dialect_initializecCst|}t|j|jjdSrz)rrr(rfrwr5r5r6test_get_default_schema_namesz4ComponentReflectionTest.test_get_default_schema_name foreign_keyorder_byr use_schemac s|r tj}nd}dddddddht|}|rDdd ||D}n ||}fd d |D}|d kr~d d dg}t||ndd d g}tt||dS)Nr r"r rrrrcSsg|]}|dr|dqS)rr5)rAZrecr5r5r6rzsz@ComponentReflectionTest.test_get_table_names..csg|]}|kr|qSr5r5rAtZ_ignore_tablesr5r6rzsrrrr)rrHrZget_sorted_table_and_fkc_namesget_table_namesrsorted) rirxrrrErpr table_namesanswerr5rr6test_get_table_namess.      z,ComponentReflectionTest.test_get_table_namescCsnt|}|rtj}nd}||}tjjjrRtt |ddgt| |dgndddg}tt ||dS)NrKrLrJ) rrrHget_view_namesrrFr3r/rrget_materialized_view_names)rirxrrprErrr5r5r6test_get_view_namess   z+ComponentReflectionTest.test_get_view_namescCs,t|}|}tt|dtjgdSrT)rZget_temp_table_namesrrrrVrirxrprFr5r5r6test_get_temp_table_names sz1ComponentReflectionTest.test_get_temp_table_namescCs$t|}|}tt|dgdSr|)rZget_temp_view_namesrrrr5r5r6test_get_temp_view_namessz0ComponentReflectionTest.test_get_temp_view_namescCs||dSrz)_test_get_commentsrirxr5r5r6test_get_commentssz)ComponentReflectionTest.test_get_commentscCs||tjjdSrz)rrrrHrr5r5r6test_get_comments_with_schemasz5ComponentReflectionTest.test_get_comments_with_schemacCst|}|j|d}t|jd|d||dft|jd|d||dft|jd|d||df|jjj}t|j||d|||fdS)NrDr r)rrQrrrrrY)rirxrErpexpno_cstr5r5r6r"s&          z*ComponentReflectionTest._test_get_comments)FFzuse_views,use_schemac Csl|r tj}nd}|jj|jj}}|r2dddg}nddg}t|}t|||fD]\} } |} |j| | d} tt | dkt | t | j D]\} }t |j | | d| | d j}|j}t|tjjr|j}td r|tjtjfkrtj}tt t|j|jtjtjtjtjtjtjtj gdkd |j |j| | d|f|j!s| | d dkst"qqPdS) NrLrKrJrrrDrrYrSr2z%s(%s), %s(%s)rT)#rrHrrrrziprr'len enumeratecolumnsrrY __class__rSrr\rZ TypeEnginerr5 sql_typesDateDateTimer4__mro__ intersectionrNumericZTimerZ_Binaryr@r)rirxZ use_viewsrrEr addressesrrprbtableZ schema_namer`irlctypeZ ctype_defr5r5r6r:s\    z(ComponentReflectionTest.test_get_columnscCs6|}|j|}t|t|d}|j||dddS)NrF)Zstrict_constraints)rXrrrZassert_tables_equal)rirxrbrcZreflected_user_tmpr5r5r6test_reflect_table_temp_tables z5ComponentReflectionTest.test_reflect_table_temp_tablecCsf|}|j|}t|}||}tt|dkt|t|jD]\}}t|j ||dqDdS)NrrY) rXrrrr'rrrrrY)rirxrbrcrpr`rrlr5r5r6test_get_temp_table_columnss  z3ComponentReflectionTest.test_get_temp_table_columnscCs0t|}|d}tdd|DdddgdS)Nr}cSsg|] }|dqSrr5rArlr5r5r6rzszFComponentReflectionTest.test_get_temp_view_columns..r>rYr)rrr)rirxrpr`r5r5r6test_get_temp_view_columnss z2ComponentReflectionTest.test_get_temp_view_columnsFc Cs|rtjj}nd}|jj|jj}}t|}|j|d}|j|j |d}| |g|||j fg|j |j|j |d} |||j fd} t | d| tj jt | ddW5QRX|jjj } | |j| |dg||| fg|j dS)NrDr^rYr )rrrHrrrrrcrrY _check_listrdrrFrafail_ifr) rirxrrErrrprZ users_consZ addr_consZexp_colsrr5r5r6rs.    z.ComponentReflectionTest.test_get_pk_constraintc CsT|r tj}nd}|jj|jj}}t|}|}tjjj r|j |j |d}|d} tjj t| ddW5QRXt| d|t| d|j t| ddgt| d d g|j |j |d} | d} tjj t| ddk W5QRXt| d|t| d|j t| ddgt| d d g|jjj } t|j | |dgdS) NrDrrYrrirjrhrr^rr)rrHrrrrrrFr%r/rrYrnrrimplicitly_named_constraintsr'r) rirxrrErrrpZexpected_schemaZ users_fkeysfkey1Z addr_fkeysrr5r5r6rs2  z-ComponentReflectionTest.test_get_foreign_keysc Cs|d|jjdtjjdtjj\}}}t|}||j}t t |d|d}t |dtjjt |d|jt |dd gt |d d g|j|jtjjd }t t |d|d} t | dd|jjfkt | d|jt | dd gt | d d gdS)Nz%s.local_tablez%s.remote_tablez%s.remote_table_2rrrirjrhr>r^rrDr) rrfr(rrrHrrrYrrr') rirxrrrrpZ local_fkeysrZ remote_fkeysZfkey2r5r5r6"test_get_inter_schema_foreign_keyss:    z:ComponentReflectionTest.test_get_inter_schema_foreign_keyscCsz|r tj}nd}t|}|jd|d}|j|d}||||df|j|jjj }||j||d|||f|jdS)NrrD) rrHrrr}rr~rrrY)rirxrrErpindexesrrr5r5r6rs"     z(ComponentReflectionTest.test_get_indexes)r r#)r"r$z tname,ixnamecCst|}||}|d|f}||||jt|t|d}tt|j dt t |j dj |tt |j dj |dS)Nrrr)rrr}rr~rrrrrr r_rrY)rirxtnameZixnamerprZexpected_indexesrr5r5r6test_get_noncol_index0s  z-ComponentReflectionTest.test_get_noncol_indexcCsBt|}|}||}|jddd|f}||||jdS)NT)r)rrXrrrr~)rirxrprY reflectedrr5r5r6&test_get_temp_table_unique_constraintsFs  z>ComponentReflectionTest.test_get_temp_table_unique_constraintscCsnt|}|}||}|D]}|ddqddgddg}tjjjrVg|dd<tdd |D|dS) NruFrr/)rrtrYrrvcSsg|]}|ddkr|qS)rYr/r5rArr5r5r6rz\s zGComponentReflectionTest.test_get_temp_table_indexes..) rrXrrVrrFindex_reflects_included_columnsr/r)rirxrprbrindexpectedr5r5r6test_get_temp_table_indexesOs     z3ComponentReflectionTest.test_get_temp_table_indexesc Cs|r tj}nd}tddgdddddgdddddgddd d gdd dgdd dgdgtd d}td|tdtdtdtdtdtj td tdtd td|d}|D]"}| tj |dd |d iq| |t |}t|jd|dtd d} t} tt|t| t|| D]B\} } | dd} | rT| | t| dddt| | q0t}td|||d} dd| jD}dd| jDdg}||rt| rt| |t|t|jjj}t|j||dgdS)NZunique_ar)rYrtZ unique_a_b_cbrZ unique_c_a_bZunique_asc_keyascrz i.have.dotsz i have spacesrYrZtesttblr rrDrtrr)rrEcSsh|] }|jqSr5rrr5r5r6 szFComponentReflectionTest.test_get_unique_constraints..cSsh|]}t|tjr|jqSr5)rr\rrY)rAZuqr5r5r6rs )rrHroperator itemgetterrrr\rrZappend_constraintrrmrrr4rrrrVrErr constraints differencerrrrrY)rirNrxrrEZuniquesrrrprZnames_that_duplicate_indexr{ZreflZdupeZreflected_metadataZ idx_namesZuq_namesrr5r5r6r`sx                z3ComponentReflectionTest.test_get_unique_constraintscCs@|r tj}nd}t|}dD]}|j||d}tt|qdS)N)rLrKrJrD)rrHrrr'bool)rirxrrErpviewrBr5r5r6rsz0ComponentReflectionTest.test_get_view_definitionc CsHt|}tt|dW5QRXtt|dW5QRXdS)NZview_does_not_existr)rrrrrwr5r5r6'test_get_view_definition_does_not_exists   z?ComponentReflectionTest.test_get_view_definition_does_not_existcCsFt|}dD]4\}}||}dd|D|}|dds tq dS)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. ))rr)rr)rrcSsi|]}|d|qSrr5rxr5r5r6rDszBComponentReflectionTest.test_autoincrement_col..rRTN)rrgetr)rirxrprcnamer`Zid_r5r5r6test_autoincrement_cols   z.ComponentReflectionTest.test_autoincrement_colc Csttj}|rtjnd}tjjjr\|jd|d}t t |t |jd|d}t t |t n"t t |jd|d}W5QRXdS)NrrDr)rrr3rHrrFrr/rr'rr2rr)rirrprErr5r5r6rs   z.ComponentReflectionTest.test_get_table_optionsc svttjtjjjrV|rtjndjd}fddj dD}t ||nt t }W5QRXdS)NrDcs i|]}|fj|dqS)rD)r)rArrprEr5r6rDszHComponentReflectionTest.test_multi_get_table_options..) rrr3rrFrr/rHget_multi_table_optionsrrrr)rirrrr5rr6test_multi_get_table_optionss       z4ComponentReflectionTest.test_multi_get_table_optionscsfdd}|S)Nc st}||d||d}|r&|}g}tj|krD|dddgtj|kr\|ddgtj|krt|ddg|r||d<|r||d <|||||d d } |g} |tjkr| } | d | | |tjkr| } | d | | t| | fS) Nr)r,rr rzdoes-not-existrKrJrEr)rEr,rrr,r) rrrr|rrrrrcopyrVappend) rEr,rrZsingle_reflect_fnZ exp_methodrprarrkwsZnkwrxr5r6provide_fixture sD           z>ComponentReflectionTest.get_multi_exp..provide_fixturer5)rirxrr5rr6 get_multi_exp s .z%ComponentReflectionTest.get_multi_expc CsH|||||tj|j\}}}|D]"} ||jf| } t| |q dSrz)rrrNrorr rirrEr,rrrprrraresultr5r5r6#test_multi_get_table_options_tables<s  z;ComponentReflectionTest.test_multi_get_table_options_tablesc CsD|||||tj|j\}}}|D]} |t|jf| |q dSrz)rrrQrorZget_multi_table_comment) rirrEr,rrrprrrar5r5r6test_get_multi_table_commentNs z4ComponentReflectionTest.test_get_multi_table_commentcsVtdddt|tr8tfdd|D||ntfdd|D||dS)NrOcSstdd|S)Nz['\" ]r)resubrrr5r5r6_clean`sz:ComponentReflectionTest._check_expressions.._cleancsi|]\}}||qSr5r5)rAerBrr5r6rDdsz>ComponentReflectionTest._check_expressions..csg|] }|qSr5r5)rArrr5r6rzfsz>ComponentReflectionTest._check_expressions..)rrr2rrG)rirrerr_msgr5rr6_check_expressions_s  z*ComponentReflectionTest._check_expressionsc Cs|dkrt|||ntt|t||t||D]~\}}t|t|BD]d}||ksh||krL||krL|d|d|}|dkr||||||qLt|||||qLq4dS)Nz - )rwrr)rrrr4r) rirrreq_keysmsgrrrrr5r5r6rhsz#ComponentReflectionTest._check_listcCs\tt|t||D]8}||||}}|rF|g|g}}|||||qdSrz)rr4keysr)rirrr make_listsrrrr5r5r6_check_table_dictvs z)ComponentReflectionTest._check_table_dictc CsN|||||tj|j\}}}|D](} ||jf| } || ||jq dSrz)rrr[roget_multi_columnsrr]rr5r5r6test_get_multi_columns~s  z.ComponentReflectionTest.test_get_multi_columnsc CsR|||||tj|j\}}}|D],} ||jf| } |j| ||jddq dS)NT)r)rrrcroZget_multi_pk_constraintrrdrr5r5r6test_get_multi_pk_constraints"  z4ComponentReflectionTest.test_get_multi_pk_constraintcCsTtjjjsP||fD]<}|D].}t|dkrtdd|Dr|j|dqqdS)Nrcss"|]}|ddtjfkVqdS)rYN)rr(r)rArBr5r5r6 sz7ComponentReflectionTest._adjust_sort..r)rrFrr/rHranysort)rirrrobjrbr5r5r6 _adjust_sorts   z$ComponentReflectionTest._adjust_sortc Cs`|||||tj|j\}}}|D]:} ||jf| } || |dd|| ||jq dS)NcSs t|dS)Nr^tupledr5r5r6rrzEComponentReflectionTest.test_get_multi_foreign_keys..)rrrproZget_multi_foreign_keysr rrqrr5r5r6test_get_multi_foreign_keyss"  z3ComponentReflectionTest.test_get_multi_foreign_keysc CsN|||||tj|j\}}}|D](} ||jf| } || ||jq dSrz)rrr}roZget_multi_indexesrr~rr5r5r6test_get_multi_indexess  z.ComponentReflectionTest.test_get_multi_indexesc Cs`|||||tj|j\}}}|D]:} ||jf| } || |dd|| ||jq dS)NcSs t|dS)Nrtr r r5r5r6rrzKComponentReflectionTest.test_get_multi_unique_constraints..)rrrroZget_multi_unique_constraintsr rrrr5r5r6!test_get_multi_unique_constraintss  z9ComponentReflectionTest.test_get_multi_unique_constraintsc Cs`|||||tj|j\}}}|D]:} ||jf| } || |dd|| ||jq dS)NcSs t|dS)Nrr r r5r5r6rrzJComponentReflectionTest.test_get_multi_check_constraints..)rrrroZget_multi_check_constraintsr rrrr5r5r6 test_get_multi_check_constraintss  z8ComponentReflectionTest.test_get_multi_check_constraintsrrrrrrrrmethodc Cs2t|}t||}tt|dW5QRXdS)NZtable_does_not_exists)rgetattrrr)rirrxrprr5r5r6test_not_existing_tables  z/ComponentReflectionTest.test_not_existing_tablec s`tjfdd}tjtd|4ttdt|t dt dW5QRXW5QRXdS)Ncs"|di}td|d<||S)NZ unreflectableerr)N some_table) setdefaultr)rrurZmcr5r6patched s  z;ComponentReflectionTest.test_unreflectable..patchedrrr) rrr(patchobjectrrrZ reflect_tablerr)rirxrr5rr6test_unreflectable s   z*ComponentReflectionTest.test_unreflectablercst}|rtjnd|j||ddt|}|}|rr||7}z||7}Wntk rpYnXrfdd|D}t t |j t |dS)NF)rErZ resolve_fkscsg|]}d|qS)rr5rrDr5r6rz7 sz9ComponentReflectionTest.test_metadata..) rrrHreflectrrrrrrrr)rirxrrmrprr5rDr6 test_metadata% s z%ComponentReflectionTest.test_metadatac Cstd|tdtddtdtdddd||t|}|d}t|ddi|d}d d |D}ddd }t||dS) Nunicode_commentsunicodeu é試蛇ẟΩremojiu ☁️✨u試蛇ẟΩ✨rOcSsi|]}|d|dqSrr5rxr5r5r6rDK szAComponentReflectionTest.test_comments_unicode..)r#r$rrrrrrrr)rirxrNrptcr`valuerr5r5r6test_comments_unicode: s      z-ComponentReflectionTest.test_comments_unicodecCsptd|tdtdddd||t|}|d}t|ddi|dd}t|d|d iddidS) Nr"r$u&🐍🧙🝝🧙‍♂️🧙‍♀️ru&🎩🁰🝑🤷‍♀️🤷‍♂️rOrrYrr%)rirxrNrpr&rr5r5r6test_comments_unicode_fullO s   z2ComponentReflectionTest.test_comments_unicode_full)N)NN)NF)mr8r9r: run_inserts run_deletesrr;rOrrXrLrJr:r<rIrrrrNrQr[propertyr]rcrdrprqr}r~rrrrrrFZschema_reflectionrrrrZschema_create_deleterrrr!foreign_key_constraint_reflectionrGrrrFrrIr_rrrrrrr-rrrr!primary_key_constraint_reflectionrrr'rr)rr*r+rrrZtemp_table_reflect_indexesrrrrtable_reflectionrrrfixturerrrrrrrrrrr rrrrrrrrr!r(Zcomment_reflection_full_unicoder)r5r5r5r6rs  .  !  - ! & `  0  X  u  E  :           #          A      & $      V        1                  rc@sheZdZdZdZejddZejddZddZ d d Z d d Z ej j d dZej j ddZdS)TableNoColumnsTest)Zreflect_tables_no_columnsTcCstd|||dSNrP)rrrirxrNr5r5r6table_no_columnse s z#TableNoColumnsTest.table_no_columnscCs<td|t|dtdt|dtd||dS)NrPrPz*CREATE VIEW empty_v AS SELECT * FROM emptyrQzDROP VIEW IF EXISTS empty_v)rrrRr rr3r5r5r6view_no_columnsj s z"TableNoColumnsTest.view_no_columnscCs$tdt|d}tt|jgdS)NrPrrrrr_r)rirxr4t2r5r5r6test_reflect_table_no_columnsz sz0TableNoColumnsTest.test_reflect_table_no_columnscCs2t|}t|dg|}t|dgidS)NrPr2)rrrr)rirxr4rpmultir5r5r6!test_get_columns_table_no_columns~ sz4TableNoColumnsTest.test_get_columns_table_no_columnscCs*t}||t|jdgs&tdSr2)rrr4rrr)rirxr4r r5r5r6"test_reflect_incl_table_no_columns s z5TableNoColumnsTest.test_reflect_incl_table_no_columnscCs$tdt|d}tt|jgdS)Nempty_vrr6)rirxr5r7r5r5r6test_reflect_view_no_columns sz/TableNoColumnsTest.test_reflect_view_no_columnscCs8t|}t|dg|jtjd}t|dgidS)Nr<)r)Nr<)rrrrrr)rirxr5rpr9r5r5r6 test_get_columns_view_no_columns sz3TableNoColumnsTest.test_get_columns_view_no_columnsN)r8r9r: __requires__rrr0r4r5r8r:r;rFrr=r>r5r5r5r6r1a s   r1c @seZdZdZejdejjfdddejjddZ ejj ddZ ejj d d Z d d Zejjd dZejjddZejjddZejdddejjfdddejjfiddejjfiddejjfdddejjfdddejjfddddZdS)ComponentReflectionTestExtraTrrrc s|r tj}nd}td|tdttjdddtjddd|dtd |td td |d||t |}t |j d|dt d d }ddfdd|D}t|ddddddgd }t|j ||dgdS)NZsa_ccrza > 1 AND a < 5Zcc1rza = 1 OR (a > 2 AND a < 5)Z UsesCasingrDrrAr rYrcSsdtd|tjS)N zand|\d|=|a|or|<|>)joinrfindallrI)rr5r5r6 normalize szJComponentReflectionTestExtra.test_get_check_constraints..normalizecs"g|]}|d|ddqS)rYrrYrr5)rAitemrEr5r6rz szKComponentReflectionTestExtra.test_get_check_constraints..za = 1 or a > 2 and a < 5rFza > 1 and a < 5)rrHrrrr\rrrrrrrrr)rirNrxrrErprrr5rHr6r sL      z7ComponentReflectionTestExtra.test_get_check_constraintsc std|tdtdtdtdtdtd}tdt|jj|jjt|jj dtdt |jjtd |jj| t }d dgd id g}fd d }||dGdddt }Gfdddt }tjjjrtddddg|dd|dgd d} || |d| ddg|ddgd d} || || t|d|t} td| d} n8td*t|d|t} td| d} W5QRX|| |jjdS)Nrxryzt_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 Z t_idx_longZt_idx_2F)rYrtrrucs:tjjjr*g|d<jjdgi|d<n |didS)NrvZ_includeru)rrFrr/rrYr)entryrr5r6 completeIndex s    zYComponentReflectionTestExtra.test_reflect_expression_based_indexes..completeIndexrc@seZdZddZdS)z[ComponentReflectionTestExtra.test_reflect_expression_based_indexes..lower_index_strcSs |}d|kod|kpd|kS)NrrIrJr)rirolr5r5r6rf szbComponentReflectionTestExtra.test_reflect_expression_based_indexes..lower_index_str.__eq__Nrgr5r5r5r6lower_index_str srQcseZdZfddZdS)z^ComponentReflectionTestExtra.test_reflect_expression_based_indexes..coalesce_index_strcsd|ko|kS)NcoalescerOrelong_strr5r6rf szeComponentReflectionTestExtra.test_reflect_expression_based_indexes..coalesce_index_str.__eq__Nrgr5rSr5r6coalesce_index_str srUzlower(x)zlower(y))rYrtrwrz coalesce(x, 'z')rz>Skipped unsupported reflection of expression-based index t_idx)rrrr!rrrrIrKrJrRrrrrrFZ reflect_indexes_with_expressionsr/insertrrrrrZ!compare_table_index_with_expectedrrY) rirNrxrrprrNrQrUZ expr_indexZexpr_index_longrr7r5)rxrTr6%test_reflect_expression_based_indexes sp   &      zBComponentReflectionTestExtra.test_reflect_expression_based_indexescCstd|tdtdtdtd}td|jj}dg|j|jjd<| |t |}| d}t |ddgdgdt jdgt |d d d |jjdgtdt|d }t t|jd j|jjddgdS) NrrIrrJrLincludeF)rYrtrvrrurruz %s_includer)rrrr!rrIrurrYrrrrr(rrr_r)rirNrxrrrprr7r5r5r6test_reflect_covering_index- sD       z8ComponentReflectionTestExtra.test_reflect_covering_indexcGs@td|fddt|D}||ddt|dDS)NrcSsg|]\}}td||qS)zt%dr )rArtype_r5r5r6rz\ szAComponentReflectionTestExtra._type_round_trip..cSsg|] }|dqS)rSr5rxr5r5r6rz` s)rrrmrr)rirxrNrrr5r5r6_type_round_tripX s z-ComponentReflectionTestExtra._type_round_tripcCsH|||tddD],}t|tjs*tt|jdt|jdqdS)Nr)r[rrrrr precisionscalerirxrNtypr5r5r6test_numeric_reflectionb s  z4ComponentReflectionTestExtra.test_numeric_reflectioncCs8|||tdd}t|tjs(tt|jddS)N4r)r[rrrrrlengthr_r5r5r6test_varchar_reflectionk sz4ComponentReflectionTestExtra.test_varchar_reflectionc CsTtd|tdtddtdtdd}||tddt|dDddd dS) NrrTrrFcSsi|]}|d|dqS)rYrr5rr5r5r6rD} szIComponentReflectionTestExtra.test_nullable_reflection..)rr)rrrrmrrr)rirxrNrr5r5r6test_nullable_reflections s    z5ComponentReflectionTestExtra.test_nullable_reflectionNZCASCADEzSET NULLz NO ACTIONZRESTRICTzexpected,ondelete,onupdatec s"i}|r||d<|r||d<|dkr(|}td|tdtddddtd|tdtddtd ttd d d td tdddtd|tdtddtdtdddtdttjdgdgfddi|dd||t|}| dddt fddDi| dddt |dS)NondeleteonupdaterIr>Tr?rrZx_idzx.idxidrtest userrYrBFrtidztable.idZmyfkrr-csi|]}|r||qSr5r5)rAroptsr5r6rD szMComponentReflectionTestExtra.test_get_foreign_key_options..) rrrrrr\rrrrr)rirxrNrrfrgr-rpr5rmr6test_get_foreign_key_options sV*      z9ComponentReflectionTestExtra.test_get_foreign_key_options)r8r9r:rrrrFrGrrZindexes_with_expressionsrWrrYr[r/rardreZ1foreign_key_constraint_option_reflection_ondeleteZ1foreign_key_constraint_option_reflection_onupdateZ1fk_constraint_option_reflection_ondelete_noactionZ1fk_constraint_option_reflection_onupdate_restrictZ1fk_constraint_option_reflection_ondelete_restrictror5r5r5r6r@ sj  5 Z *    'r@c@s0eZdZdZdZeddZddZddZd S) NormalizedNameTest)Zdenormalized_namesTcCsLttddd|tdtddttddd|tdtddtdtddS) NrTrr>r?r7t1idzt1.id)rr"rrrrMr5r5r6rO s     z NormalizedNameTest.define_tablescCs~t}ttddd|tjd}|jd}|jj|jj s>t t}|j tjddd|jdjj|jdjj szt dS) Nr7TrqrrcSs |dkS)Nrr7rO)rYr r5r5r6r rzINormalizedNameTest.test_reflect_lowercase_forced_tables..)only) rrr"rr3rrrrrr>rr)rirZt2_refZt1_refZm3r5r5r6$test_reflect_lowercase_forced_tables s  z7NormalizedNameTest.test_reflect_lowercase_forced_tablescCsPddttjD}t|d|dt|d|ddS)NcSsg|]}|dkr|qS)rsrOrr5r5r6rz s z;NormalizedNameTest.test_get_table_names..rr)rrr3rrupperr)riZ tablenamesr5r5r6r s  z'NormalizedNameTest.test_get_table_namesN) r8r9r:r?rr;rOrurr5r5r5r6rp s  rpc@s<eZdZddZddZddZddZejj d d Z d S) ComputedReflectionTestcCs^ttj}|d}dd|D}td|ddkt|dddt|ddddS) Ncomputed_default_tablecSsi|]}|d|qSrr5rxr5r5r6rD szLComputedReflectionTest.test_computed_col_default_not_set..Z42 with_defaultrTnormal computed_col)rrr3rr'r )rirpr`Zcol_datar5r5r6!test_computed_col_default_not_set s   z8ComputedReflectionTest.test_computed_col_default_not_setcCsttj}|d}dd|D}dD]}td||kq&|d}td|ktd|dkt||dddtd |dktjj j tjj j rt|dd tjj j dS) NrxcSsi|]}|d|qSrr5rxr5r5r6rD szKComputedReflectionTest.test_get_column_returns_computed..)r>rzrycomputedr{r normal+42 persisted) rrr3rr'rrErrF"computed_columns_reflect_persistedr/"computed_columns_default_persisted)rirpr`rArcompDatar5r5r6 test_get_column_returns_computed s$      z7ComputedReflectionTest.test_get_column_returns_computedcCsXtd||k||d}t||d|tjjjrTtd|kt|d|dS)Nr}rr)r'rrErrFrr/r )rirAcolumnrrrr5r5r6 check_column, s    z#ComputedReflectionTest.check_columncCspttj}|d}dd|D}||ddtjjjtjj jrR||dddtjj jrl||d d d dS) Ncomputed_column_tablecSsi|]}|d|qSrr5rxr5r5r6rD8 szLComputedReflectionTest.test_get_column_returns_persisted..computed_no_flagr~computed_virtualznormal+2Fcomputed_storedz normal-42T) rrr3rrrrFrr/computed_columns_virtualcomputed_columns_storedrirpr`rAr5r5r6!test_get_column_returns_persisted4 s.    z8ComputedReflectionTest.test_get_column_returns_persistedcCsvttj}|jdtjd}dd|D}||ddtjjj tjj j rX||ddd tjj j rr||d d d dS) NrrDcSsi|]}|d|qSrr5rxr5r5r6rDV szXComputedReflectionTest.test_get_column_returns_persisted_with_schema..rz normal/42rznormal/2Frz normal*42T) rrr3rrHrrrFrr/rrrr5r5r6-test_get_column_returns_persisted_with_schemaO s4   zDComputedReflectionTest.test_get_column_returns_persisted_with_schemaN) r8r9r:r|rrrrrFrGrr5r5r5r6rw s  rwc@sHeZdZdZZdZdZeddZddZ dd Z e j j d d ZdS) IdentityReflectionTestNT)Zidentity_columnsr/cCs|td|tdttdtttd|tdttdddd d dd d tjjjrxtd|tdttdttdd dtj ddS)Nrrzid1r7rTrrralwaysstart incrementminvaluemaxvaluecyclecacher )rrrD) rrrrrrFrGr/rrHrMr5r5r6rOt s>  z$IdentityReflectionTest.define_tablescCstjjjrd}t|D]}||kr||q|rtt|t||D]T}|dkrjt||||kqH|dkrt||||kqHt|||||qHqt||n$t|d|dt|d|ddS)Nrr>rrrr) rrFZidentity_columns_standardr/r_rVrrr')rir'rapproxZ common_keysrr5r5r6check s     zIdentityReflectionTest.checkc Csttj}|d|d}|D]}|ddkr@td|kq"|ddkrd|kr`t|dt|ddtd|k|j|dtd d d d d d d d d dq"|ddkr"d|krt|dt|ddtd|k|j|dtd ddddd dd d dq"dS)Nrr7rYrzidentityrrRrTFrrTrrrrrrr) rrr3rr&r'rrr2rirpr`rlr5r5r6test_reflect_identity sR          z,IdentityReflectionTest.test_reflect_identityc Csttj}|jdtjd}|D]~}|ddkrattrrYr Zpk_tb1rTrtb2r?pidpattrpnameZfk_tb1_name_id_attr) rrrrr^r\rrrrYr>r)r4rNrr5r5r6rO s2  z(CompositeKeyReflectionTest.define_tablescCs2t|}||jjj}t|ddddgdS)Nr^rYr>r)rrrrrYrr)rirxrpr@r5r5r6test_pk_column_order sz/CompositeKeyReflectionTest.test_pk_column_ordercCs^t|}||jjj}tt|d|d}t|ddddgt|ddd d gdS) NrrrhrYr>rr^rrr)rrrrrYrrr)rirxrpZ foreign_keysrr5r5r6test_fk_column_order! s z/CompositeKeyReflectionTest.test_fk_column_orderN) r8r9r:rr;rOrrFr.rr-rr5r5r5r6r s  r) rr@r1rrr<rrprwrr)Crrr0r\rrrrrrrr r Z provisionr r rErrrrrrrrrrrrrrrrrexcrrr r!Z sql.elementsr"Z sql.schemar#r$r%r&r'r(rNrZ TablesTestr)r<rZTestBaserrrrr1r@rpZComputedReflectionFixtureTestrwrr__all__r5r5r5r6 s                                    L;Y5N+a1