U a@sddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd l m Z dd l mZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!d\Z"Z#Gddde j$Z%Gd d!d!e j$Z&Gd"d#d#e j$Z'Gd$d%d%e j$Z(Gd&d'd'e j)Z*Gd(d)d)e j$Z+Gd*d+d+e j,Z-Gd,d-d-e j$Z.Gd.d/d/e j$Z/d0Z0dS)1N)func)config)engines)eq_)expect_warnings)fixtures)is_)get_temp_table_name)temp_table_keyword_argsColumn)Table)event) ForeignKey)Identity)inspect)Integer)MetaData)String)testing)types)DDL)Index) quoted_name)is_false)is_true)NNc@s4eZdZdZeddZddZejj ddZ dS) HasTableTestTcCsXtd|tdtddtdtdtjjjrTtd|tdtddtdtdtj ddS) N test_tableidT primary_keydata2 test_table_sschema) rr rrrrequiresschemasenabledr test_schemaclsmetadatar/iC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\testing\suite\test_reflection.py define_tables&s     zHasTableTest.define_tablesc CsVtjB}ttjj|dttjj|dttjj|dW5QRXdS)Nrr%nonexistent_table)rdbbeginrdialect has_tablerselfconnr/r/r0test_has_table7s zHasTableTest.test_has_tablec CshtjT}ttjjj|dtjdttjjj|dtjdttjjj|dtjdW5QRXdS)Nrr&r%r2)rr3r4rr5r6r+rr7r/r/r0test_has_table_schema=s, z"HasTableTest.test_has_table_schemaN) __name__ __module__ __qualname__ __backend__ classmethodr1r:rr(r)r;r/r/r/r0r#s  rc@s4eZdZdZeddZddZejj ddZ dS) HasIndexTestTcCsttd|tdtddtdtd}td|jjtjj j rptd|tdtddtdtdt j d}td |jjdS) Nrr Tr!r#r$my_idxr&my_idx_s) rr rrrcr#rr(r)r*rr+)r-r.ttr/r/r0r1Ts      zHasIndexTest.define_tablesc Csrtj^}tjj|dds"ttjj|ddr8ttjj|ddrNttjj|ddrdtW5QRXdS)NrrBrCr2Znonexistent_idx)rr3r4r5 has_indexAssertionErrorr7r/r/r0test_has_indexhs" zHasIndexTest.test_has_indexc Cstjv}tjjj|ddtjds(ttjjj|ddtjdrDttjjj|ddtjdr`ttjjj|ddtjdr|tW5QRXdS)NrrCr&rBr2Znonexistent_idx_s)rr3r4r5rFr+rGr7r/r/r0test_has_index_schemaus2    z"HasIndexTest.test_has_index_schemaN) r<r=r>r?r@r1rHrr(r)rIr/r/r/r0rAQs   rAc@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 namer$r#Z related_idzpk quote ' onerMzix quote ' onez uq quote' onez related.idzfk quote ' onez name != 'foo'zck quote ' onezquote ' one commentT)comment test_needs_fk quote " twozpk quote " twozix quote " twoz uq quote" twozfk quote " twozck quote " two zquote " two commentrelatedr!rP"CREATE VIEW %s AS SELECT * FROM %sview %s after_create before_drop DROP VIEW %s)rr rrsaPrimaryKeyConstraintrUniqueConstraintForeignKeyConstraintCheckConstraintrr(symbol_names_w_double_quoter*view_column_reflectionrr3r5Zidentifier_preparerquoterlistenr)r-r.namesrMqueryr/r/r0r1s                z$QuotedNameArgumentTest.define_tablescCstddtjjf|S)N)rLrQ)r combinationsr(r^)fnr/r/r0quote_fixturess  z%QuotedNameArgumentTest.quote_fixturescCsttj}||dSN)rrr3Zget_table_optionsr8rMinspr/r/r0test_get_table_optionss z-QuotedNameArgumentTest.test_get_table_optionscCs ttj}|d|stdS)NrU)rrr3get_view_definitionrGrhr/r/r0test_get_view_definitions z/QuotedNameArgumentTest.test_get_view_definitioncCsttj}||stdSrg)rrr3 get_columnsrGrhr/r/r0test_get_columnss z'QuotedNameArgumentTest.test_get_columnscCsttj}||stdSrg)rrr3get_pk_constraintrGrhr/r/r0test_get_pk_constraints z-QuotedNameArgumentTest.test_get_pk_constraintcCsttj}||stdSrg)rrr3get_foreign_keysrGrhr/r/r0test_get_foreign_keyss z,QuotedNameArgumentTest.test_get_foreign_keyscCsttj}||stdSrg)rrr3 get_indexesrGrhr/r/r0test_get_indexess z'QuotedNameArgumentTest.test_get_indexescCsttj}||stdSrg)rrr3get_unique_constraintsrGrhr/r/r0test_get_unique_constraints s z2QuotedNameArgumentTest.test_get_unique_constraintscCsttj}||stdSrg)rrr3get_table_commentrGrhr/r/r0test_get_table_comments z-QuotedNameArgumentTest.test_get_table_commentcCsttj}||stdSrg)rrr3get_check_constraintsrGrhr/r/r0test_get_check_constraintss z1QuotedNameArgumentTest.test_get_check_constraintsN)r<r=r>Zrun_create_tablesr?r@r1rfrjrr(r_rlrnrprrrtunique_constraint_reflectionrvcomment_reflectionrxcheck_constraint_reflectionrzr/r/r/r0rJs6 S        rJc @s&eZdZdZZdZeddZeddZeddZ ed d Z ed d Z ed dZ e jjddZe jjddZe jjddZe jje jddddde jjfdddddde jjfddddde jjfddddZe jjddZe jje jje jjd d!Ze jjd"d#Ze jje jjd$d%ZdRd&d'Ze jd(dde jjfdde jjfdde jje jjfd)dd*d+Z e jj!d,d-Z"e jj!e jj#e jjd.d/Z$e jd0de jjfd1de jj%d2d3Z&e jd0de jjfd1de jjd4d5Z'e jj(e jjd6d7Z)d8d9Z*e jd0de jjfd1dd:d;Z+e jdde jj,e jj-d?d@Z.e jj!e jj/dAdBZ0e jj1dCdDZ2e jde jjfd0d1de jj/dEdFZ3e jje jd0de jjfd1ddGdHZ4e jdIdJde jjfdKde 5dLdMdNdOZ6e jj7dPdQZ8dS)SComponentReflectionTestNTcCs6tjjjr,ddlm}tjt|j dddStj SdS)Nr)poolclass)Z poolclassZscope)options) r requirementsZindependent_connectionsr* sqlalchemyrrtesting_enginedictZ StaticPoolr3)r-rr/r/r0 setup_bind"s    z"ComponentReflectionTest.setup_bindcCs*||dtjjjr&||tjjdSrg)define_reflected_tablesrr(r)r*rr+r,r/r/r0r1-s  z%ComponentReflectionTest.define_tablesc Cs$|r|d}nd}tjjjrztd|tdtjddtdtdd d td t dd d td tj tj d |dd|dd}nBtd|tdtjddtdtdd d td t dd d |dd}td|tdtj ddtdtj t d|tdt d|ddtd|tdtj tdtj t |j jtdt dtjddd|ddtd|tdtj dddtdt dd d!td"t dd#d!|d$d%tjjjrX|dkrtd&|tdtj ddtdt dtd't d(tjjdtjjjd)nntd*|tdtj ddtd+t d,tjjjtdt d|ddtd-|tdtj ddtdt d|ddtjjjr||||std.|td/t ddd0}td1|tdtj ddtd/t ddd0}tjjjrtd2|j jtd3|j jtjjjr||||s tjjjr ||dS)4N.usersuser_idTr!test1Fnullabletest2parent_user_idz%susers.user_id user_id_fkrNr'rP dingalings dingaling_id address_idz%semail_addresses.address_idr#email_addressesremote_user_idZ email_address email_ad_pk comment_testr id comment)r"rOdata % comment)rOd2)Comment types type speedily ' " \ '' Fun!the test % ' " \ table comment)r'rO local_table remote_idz%s.remote_table_2.id)rPr' remote_tablelocal_idz%s.local_table.idremote_table_2noncol_idx_test_nopkqrSnoncol_idx_test_pknoncol_idx_nopk noncol_idx_pk) rr(self_referential_foreign_keysr*rr rYINTCHARZFloatrrrrDrrZcross_schema_fk_reflectionrr+r3r5default_schema_nameindex_reflection define_indexindexes_with_ascdescrrdescr_ define_viewstemp_table_reflectiondefine_temp_tables)r-r.r'Z schema_prefixrrrr/r/r0r3s                  z/ComponentReflectionTest.define_reflected_tablesc Cstttj}tttjdtj}t||tdtjddtdt dtdtjtj ddtjd t d df|}t j jjrt j jjrt|d td tjt|d tddS)N user_tmp_%sr Tr!rMr$foouser_tmp_uq_%srN user_tmp_ixrVz=create temporary view user_tmp_v as select * from user_tmp_%srWzdrop view user_tmp_v)r rr3r identrr rYrVARCHARr[rrr(view_reflectionr*temporary_viewsrrar)r-r.kw table_nameuser_tmpr/r/r0rs>   z*ComponentReflectionTest.define_temp_tablescCs2td|jj|jjtd|jj|jj|jjdS)N users_t_idx users_all_idx)rrDrrr)r-r.rr/r/r0rsz$ComponentReflectionTest.define_indexcCs^dD]T}|}|rd||f}|d}d||f}t|dt|t|dtd|qdS)N)rrz%s.%sZ_vrTrVrWrX)rrar)r-r.r'rfullnameZ view_namercr/r/r0rs  z$ComponentReflectionTest.define_viewscCs$t|j}|tjj|kdSrg)rbindassert_rrr+Zget_schema_namesr8rir/r/r0test_get_schema_namess z-ComponentReflectionTest.test_get_schema_namescCs$t}t|t|jds tdS)Nr)rrrhasattrr5rG)r8enginer/r/r0test_dialect_initializesz/ComponentReflectionTest.test_dialect_initializecCs t|j}t|j|jjjdSrg)rrrrr5rr/r/r0test_get_default_schema_name s z4ComponentReflectionTest.test_get_default_schema_name)NTFFF) foreign_keyTFF)NFTF)NTTFz/order_by,include_plain,include_views,use_schemaargnamesc s|r tj}nd}ddddddgt|}|rT||}|ddg} tt|| |r|rrd d ||D} n ||} fd d | D}|d krd ddg} t|| nddd g} tt|| dS)Nrrrrrremail_addresses_vusers_vcSsg|]}|dr|dqS)rr/.0Zrecr/r/r0 5sz@ComponentReflectionTest.test_get_table_names..csg|]}|kr|qSr/r/rtZ_ignore_tablesr/r0r<srrrr) rr+rZget_view_namessortrsortedZget_sorted_table_and_fkc_namesget_table_names) r8 connectionZorder_byZ include_plainZ include_views use_schemar'ri table_namesZanswertablesr/rr0test_get_table_namess8      z,ComponentReflectionTest.test_get_table_namescCs,t|j}|}tt|dtjgdS)Nr)rrZget_temp_table_namesrrrrr8ritemp_table_namesr/r/r0test_get_temp_table_namesEs z1ComponentReflectionTest.test_get_temp_table_namescCs&t|j}|}tt|dgdS)N user_tmp_v)rrZget_temp_view_namesrrrr/r/r0test_get_temp_view_namesKs z0ComponentReflectionTest.test_get_temp_view_namescCs |dSrg)_test_get_commentsr8r/r/r0test_get_commentsSsz)ComponentReflectionTest.test_get_commentscCs|tjjdSrg)rrrr+rr/r/r0test_get_comments_with_schemaWsz5ComponentReflectionTest.test_get_comments_with_schemacCstt|j}t|jd|dddit|jd|ddditdd|jd|dDdd d d d d d dd gdS)Nrr&textrrcSsg|]}|d|ddqS)rMrO)rMrOr/rr/r/r0rgsz>ComponentReflectionTest._test_get_comments..rr )rOrMrr#rr)rrrrwrm)r8r'rir/r/r0r\s"   z*ComponentReflectionTest._test_get_comments)FFzuse_views,use_schemacCsn|r tj}nd}|jj|jj}}|r0ddg}nddg}t|}t|||fD]\} } |} |j| | d} |t | dkt | t | j D]\} }t |j | | d| | dj}|j}t|tjjr|j}td r|tjtjfkrtj}|t t|j|jtjtjtjtjtjtjtj gdkd |j |j| | d|f|j!s| | d dkst"qqNdS) Nrrrrr&rrMtypeZoraclez%s(%s), %s(%s)default)#rr+rrrrziprmrlen enumeratecolumnsrrM __class__r isinstancerYrZ TypeEnginerZagainst sql_typesDateDateTimeset__mro__ intersectionrNumericZTimerZ_Binaryr"rG)r8rZ use_viewsrr'r addressesrrirtableZ schema_namecolsicolctypeZ ctype_defr/r/r0rnws\    z(ComponentReflectionTest.test_get_columnscCsvtt|jdtj}|j|}t|j}||}|t|dkt|t |j D]\}}t |j ||dqTdS)NrrrM) r rrrrrrmrrrrrrM)r8rrrirrrr/r/r0test_get_temp_table_columnss   z3ComponentReflectionTest.test_get_temp_table_columnscCs2t|j}|d}tdd|DdddgdS)NrcSsg|] }|dqSrNr/rrr/r/r0rszFComponentReflectionTest.test_get_temp_view_columns..r rMr)rrrmr)r8rirr/r/r0test_get_temp_view_columnss  z2ComponentReflectionTest.test_get_temp_view_columnsFrc Cs|rtjj}nd}|jj|jj}}t|}|j|j|d}|d}t |dg|j|j|d} | d} t | dgtj j t | ddW5QRXdS)Nr&constrained_columnsrrrMr) rrr+rrrrrorMrr(Zreflects_pk_namesfail_if) r8rrr'rrriZ users_consZ users_pkeysZ addr_consZ addr_pkeysr/r/r0rps   z.ComponentReflectionTest.test_get_pk_constraintc CsB|r tj}nd}|jj|jj}}t|}|}tjjj r|j |j |d}|d} tjj t| ddW5QRXt| d|t| d|j t| ddgtjjj rt| d d g|j |j |d} | d} tjj || ddk W5QRXt| d|t| d|j t| ddgt| d d gdS) Nr&rrMrreferred_schemareferred_tablereferred_columnsrrrr)rr+rrrrrr(rr*rqrMZnamed_constraintsrrZimplicitly_named_constraintsr) r8rrr'rrriZexpected_schemaZ users_fkeysfkey1Z addr_fkeysr/r/r0rrs0  z-ComponentReflectionTest.test_get_foreign_keysc Cs|d|jjjdtjjdtjj\}}}t|j}||j }t t |d|d}t |dtjjt |d|j t |dd gt |d d g|j|j tjjd }t t |d|d}|dd|jjjfkst t |d|j t |dd gt |d d gdS)Nz%s.local_tablez%s.remote_tablez%s.remote_table_2rrrrr rrr&r) rrr5rrrr+rrqrMrrrG) r8rrrriZ local_fkeysr Z remote_fkeysZfkey2r/r/r0"test_get_inter_schema_foreign_keyss4      z:ComponentReflectionTest.test_get_inter_schema_foreign_keyscCsZdd|D}|D]B}|d|ks&t|||d}|D]}t||||q.rM)rGindexr)r8indexesexpected_indexesZ index_namesZe_indexr keyr/r/r0_assert_insp_indexes9s z,ComponentReflectionTest._assert_insp_indexescCsZ|r tj}nd}t|j}|jd|d}dddgddddddgd dg}|||dS) Nrr&Frrrunique column_namesrMrr)rr+rrrsr)r8rrr'rirrr/r/r0rtAs  z(ComponentReflectionTest.test_get_indexes)rr)rrz tname,ixnamecCszt|}||}d|dg}|||t|t|d}tt|jdtt |jdj |tt |jdj |dS)NF)rrM autoload_withr r) rrsrrrrrrr listrrM)r8rtnameZixnamerirrrr/r/r0test_get_noncol_index]s   z-ComponentReflectionTest.test_get_noncol_indexcCsNt|j}|dtj}|D]}|ddqt|dgdtjdgdS)Nrduplicates_indexrMr)rrM)rrrurrpopr)r8ri reflectedreflr/r/r0&test_get_temp_table_unique_constraintsss z>ComponentReflectionTest.test_get_temp_table_unique_constraintscCs|t|j}tttjdtj}||}|D]}|ddq,ddgddg}tj j j rdg|dd<t d d |D|dS) Nrdialect_optionsFrrrrinclude_columnscSsg|]}|ddkr|qS)rMrr/ridxr/r/r0rs zGComponentReflectionTest.test_get_temp_table_indexes..) rrr rr3rrsrrr(index_reflects_included_columnsr*r)r8rirrindexpectedr/r/r0test_get_temp_table_indexess"      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} t|| D]0\} } | dd} | rB| | t| | qt}td|||d} tdd| jD}tdd| jDdg}||rt| rt| |t|tdS)NZunique_aa)rMrZ unique_a_b_cbrDZ unique_c_a_bZunique_asc_keyZascrz i.have.dotsz i have spacesrMrZtesttblrrr&rr)rr'cSsg|] }|jqSr/rNr!r/r/r0rszGComponentReflectionTest.test_get_unique_constraints..cSsg|]}t|tjr|jqSr/)rrYr[rM)rZuqr/r/r0rs )rr+roperator itemgetterrr rYrrZappend_constraintr[createrrurrraddrrr constraints differencerrG)r8r.rrr'ZuniquesrZuc inspectorrZnames_that_duplicate_indexorigrZdupeZreflected_metadataZ idx_namesZuq_namesr/r/r0rvst              z3ComponentReflectionTest.test_get_unique_constraintsc CsT|r tj}nd}d}d}t|}|j||d}|||j||d}||dS)Nrrr&)rr+rrkr) r8rrr'Z view_name1Z view_name2riZv1Zv2r/r/r0rls z0ComponentReflectionTest.test_get_view_definition)rFrztable_name,use_schemaZ postgresqlzPG specific featurecCs8|r tj}nd}t|}|||}|t|tdSrg)rr+rZ get_table_oidrrint)r8rrrr'rioidr/r/r0test_get_table_oids  z*ComponentReflectionTest.test_get_table_oidcCsHt|j}dD]4\}}||}dd|D|}|ddstqdS)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|qSrNr/rrDr/r/r0 &szBComponentReflectionTest.test_autoincrement_col.. autoincrementTN)rrrmgetrG)r8rircnamerZid_r/r/r0test_autoincrement_cols    z.ComponentReflectionTest.test_autoincrement_col)N)9r<r=r> run_inserts run_deletesr?r@rr1rrrrrr(Zschema_reflectionrrr!foreign_key_constraint_reflectionrdr)rrrrrrr|rrrrnrrr_r!primary_key_constraint_reflectionrprrrr rrtrrrr{rZtemp_table_reflect_indexesr&rvrlZonly_onr4table_reflectionr:r/r/r/r0r~s    #      ,       ?     $ !      R     r~c @seZdZdZejdejjfdddejjddZ ejj ddZ ejj d d Z d d Zejjd dZejjddZejjddZejdddejjfdddejjfiddejjfiddejjfdddejjfdddejjfddddZdS)ComponentReflectionTestExtraTrrrc s|r tj}nd}td|tdttjdddtjddd|d||t|}t |j d|dt d d }d d fd d|D}t |ddddddgdS)NZsa_ccr'za > 1 AND a < 5Zcc1rNza = 1 OR (a > 2 AND a < 5)Zcc2r&rMr)cSsdtd|tjS)N zand|\d|=|a|or|<|>)joinrefindalllowerI)sqltextr/r/r0 normalizeLszJComponentReflectionTestExtra.test_get_check_constraints..normalizecs"g|]}|d|ddqS)rMrGrMrGr/)ritemrHr/r0rQszKComponentReflectionTestExtra.test_get_check_constraints..za > 1 and a < 5rIza = 1 or a > 2 and a < 5)rr+rr rrYr] create_allrrryr*r+r)r8r.rrr'r0rr/rKr0rz.s6      z7ComponentReflectionTestExtra.test_get_check_constraintsc Cstd|tdtdtdtd}tdt|jjt|jjtd|jj| |t |}ddgddg}t j j jrg|d d <td t|d|W5QRXdS) Nrxryt_idxZt_idx_2F)rMrrrr z>Skipped unsupported reflection of expression-based index t_idx)rr rrrrErDrMrNrLrrr(r#r*rrrs)r8r.rrrir%r/r/r0%test_reflect_expression_based_indexes]s*       zBComponentReflectionTestExtra.test_reflect_expression_based_indexescCsztd|tdtdtdtd}td|jj}dg|j|jjd<| |t |}t | dddgdgddgdS) NrrMrrNrOincludeF)rMrr r) rr rrrDrMrrrMrLrrrs)r8r.rrr"rir/r/r0test_reflect_covering_index|s&   z8ComponentReflectionTestExtra.test_reflect_covering_indexcGs@td|fddt|D}||ddt|dDS)NrcSsg|]\}}td||qS)zt%dr )rrtype_r/r/r0rszAComponentReflectionTestExtra._type_round_trip..cSsg|] }|dqS)rr/r5r/r/r0rs)rrr,rrm)r8rr.rrr/r/r0_type_round_trips z-ComponentReflectionTestExtra._type_round_tripcCsH|||tddD],}t|tjs*tt|jdt|jdqdS)Nr)rTrrrrGrZ precisionZscaler8rr.typr/r/r0test_numeric_reflections  z4ComponentReflectionTestExtra.test_numeric_reflectioncCs8|||tdd}t|tjs(tt|jddS)N4r)rTrrrrGrlengthrVr/r/r0test_varchar_reflectionsz4ComponentReflectionTestExtra.test_varchar_reflectionc CsXtd|tdtddtdtdd}||ttddt|dDddd dS) Nrr'Trr(Fcss|]}|d|dfVqdS)rMrNr/rr/r/r0 szHComponentReflectionTestExtra.test_nullable_reflection..)r'r()rr rr,rrrrm)r8rr.rr/r/r0test_nullable_reflections    z5ComponentReflectionTestExtra.test_nullable_reflectionNZCASCADEzSET NULLz NO ACTIONZRESTRICTzexpected,ondelete,onupdatec s(i}|r||d<|r||d<|dkr(|}td|tdtddddtd|tdtddtd ttjd d d td tdddtd|tdtddtdtdddtdttjdgdgfddi|dd||t|}| dddt t fddDi| dddt |dS)NondeleteonupdaterMr Tr!rSrZx_idzx.idxidrNtest userrMr$Frtidztable.idZmyfkrrc3s"|]}|r||fVqdSrgr/)rkoptsr/r0r\szLComponentReflectionTestExtra.test_get_foreign_key_options..) rr rrYrrr\rLrrqrr)r8rr.r%r^r_rrir/rfr0test_get_foreign_key_optionssV*      z9ComponentReflectionTestExtra.test_get_foreign_key_options)r<r=r>r?rrdr(r)r}rzZindexes_with_expressionsrPr#rRrTr?rXr[r]Z1foreign_key_constraint_option_reflection_ondeleteZ1foreign_key_constraint_option_reflection_onupdateZ1fk_constraint_option_reflection_ondelete_noactionZ1fk_constraint_option_reflection_onupdate_restrictZ1fk_constraint_option_reflection_ondelete_restrictrhr/r/r/r0r@*sj  +      'r@c@s0eZdZdZdZeddZddZddZd S) NormalizedNameTest)Zdenormalized_namesTcCsLttddd|tdtddttddd|tdtddtdtddS) Nt1Tr`r r!t2t1idzt1.id)rrr rrr,r/r/r0r1%s     z NormalizedNameTest.define_tablescCs~t}ttddd|tjd}|jd}|jj|jj s>t t}|j tjddd|jdjj|jdjj szt dS) NrlTrkrrjcSs |dkS)NrjrlrE)rMmr/r/r0>zINormalizedNameTest.test_reflect_lowercase_forced_tables..)only) rrrrr3rrDrmZ referencesr rGZreflect)r8m2Zt2_refZt1_refZm3r/r/r0$test_reflect_lowercase_forced_tables3s  z7NormalizedNameTest.test_reflect_lowercase_forced_tablescCsPddttjD}t|d|dt|d|ddS)NcSsg|]}|dkr|qS)rnrorr/r/r0rCs z;NormalizedNameTest.test_get_table_names..rr )rrr3rrupperrE)r8Z tablenamesr/r/r0rBs  z'NormalizedNameTest.test_get_table_namesN) r<r=r> __requires__r?r@r1rurr/r/r/r0ri!s  ric@s<eZdZddZddZddZddZejj d d Z d S) ComputedReflectionTestcCs^ttj}|d}dd|D}td|ddkt|dddt|ddddS) Ncomputed_default_tablecSsi|]}|d|qSrNr/r5r/r/r0r6RszLComputedReflectionTest.test_computed_col_default_not_set..Z42 with_defaultrnormal computed_col)rrr3rmrr )r8rirZcol_datar/r/r0!test_computed_col_default_not_setNs   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) NrycSsi|]}|d|qSrNr/r5r/r/r0r6[szKComputedReflectionTest.test_get_column_returns_computed..)r r{rzcomputedr|rG normal+42 persisted) rrr3rmrrrHrr("computed_columns_reflect_persistedr*"computed_columns_default_persisted)r8rirr#rcompDatar/r/r0 test_get_column_returns_computedWs$      z7ComputedReflectionTest.test_get_column_returns_computedcCsXtd||k||d}t||d|tjjjrTtd|kt|d|dS)Nr~rGr)rrrHrr(rr*r )r8r#columnrGrrr/r/r0 check_columnls    z#ComputedReflectionTest.check_columncCspttj}|d}dd|D}||ddtjjjtjj jrR||dddtjj jrl||d d d dS) Ncomputed_column_tablecSsi|]}|d|qSrNr/r5r/r/r0r6xszLComputedReflectionTest.test_get_column_returns_persisted..computed_no_flagrcomputed_virtualznormal+2Fcomputed_storedz normal-42T) rrr3rmrrr(rr*computed_columns_virtualcomputed_columns_storedr8rirr#r/r/r0!test_get_column_returns_persistedts.    z8ComputedReflectionTest.test_get_column_returns_persistedcCsvttj}|jdtjd}dd|D}||ddtjjj tjj j rX||ddd tjj j rr||d d d dS) Nrr&cSsi|]}|d|qSrNr/r5r/r/r0r6szXComputedReflectionTest.test_get_column_returns_persisted_with_schema..rz normal/42rznormal/2Frz normal*42T) rrr3rmr+rrr(rr*rrrr/r/r0-test_get_column_returns_persisted_with_schemas4   zDComputedReflectionTest.test_get_column_returns_persisted_with_schemaN) r<r=r>r}rrrrr(r)rr/r/r/r0rxMs  rxc@sHeZdZdZZdZdZeddZddZ dd Z e j j d d ZdS) IdentityReflectionTestNT)Zidentity_columnsr?cCs|td|tdttdtttd|tdttdddd d dd d tjjjrxtd|tdttdttdd dtj ddS)Nrjr{id1rlid2Trr*alwaysstart incrementminvaluemaxvaluecyclecacher)rrr&) rr rrrr(r)r*rr+r,r/r/r0r1s>  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) rr(Zidentity_columns_standardr*rrrrr)r8valueexpapproxZ common_keysrer/r/r0checks     zIdentityReflectionTest.checkc Csttj}|d|d}|D]}|ddkr@td|kq"|ddkrt|ddkt|d dtd|k|j|dtd d d d d d d d ddq"|ddkr"t|ddkt|d dtd|k|j|dtdddddddd d dq"dS)NrjrlrMr{identityrr7TautorFr rTrrrrrrr) rrr3rmrrrrrr8rirrr/r/r0test_reflect_identitysN        z,IdentityReflectionTest.test_reflect_identityc Csttj}|jdtjd}|D]z}|ddkrr;r<r?rwr@r1rrrr(r)rr/r/r/r0rs !*rc@s<eZdZdZeddZejjddZ ejj ddZ dS) CompositeKeyReflectionTestTc Cstd|tdttdttdtdtjdddddddd }td |tdtdd td ttd ttdtdtjdd d g|jj |jj |jj gddddd dS)Ntb1r attrrMrZpk_tb1rNTrtb2r!pidpattrpnameZfk_tb1_name_id_attr) rr rrrrYrZr\rDrMr r)r-r.rr/r/r0r1;s2  z(CompositeKeyReflectionTest.define_tablescCs4t|j}||jjj}t|ddddgdS)NrrMr r)rrrorrrMrr8)r8rir"r/r/r0test_pk_column_orderWs z/CompositeKeyReflectionTest.test_pk_column_ordercCs`t|j}||jjj}tt|d|d}t|ddddgt|ddd d gdS) Nr rrrMr rrrrr) rrrqrrrMrrr8)r8riZ foreign_keysr r/r/r0test_fk_column_order^s  z/CompositeKeyReflectionTest.test_fk_column_orderN) r<r=r>r?r@r1rr(r>rr=rr/r/r/r0r8s  r) r~r@rJrrArirxrr)1r*rCrrYrrrrrrrr Z provisionr r r'r rrrrrrrrrrrrrZ sql.elementsrrrr.rZ TablesTestrrArJr~ZTestBaser@riZComputedReflectionFixtureTestrxrr__all__r/r/r/r0s^                         .;x,a 1