U kf@sddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd l m Z Gd d d e j ZdS)) bindparam)Column)Integer)MetaData)select)String)Table)testing)text)eq_)fixturesc@seZdZdZdZdZeddZeddZdd Z e d d d d dge dddgddZ ddZ ddZe dddge dd e jjfd e jjfgddZddZddZdd Ze jjd!d"Ze jjd#d$Zd%S)& RowCountTestztest rowcount functionality)Z sane_rowcountTc Cs4td|tdtdddtdtdtdtd dS) N employees employee_idFTZ autoincrementZ primary_keyname2 department)rrrr)clsmetadatarV/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/testing/suite/test_rowcount.py define_tabless  zRowCountTest.define_tablesc CsFddddddddd g |_}|jj}||d d t|DdS) N)ZAngelaA)ZAndrewr)ZAnandr)BobB)ZBobetter)ZBuffyr)ZCharlieC)Cynthiar)ZChrisrcSs g|]\}\}}|||dqS)rrrr).0indrrr <s z,RowCountTest.insert_data..)datatablesrexecuteinsert enumerate)r connectionr%employees_tablerrr insert_data+s" zRowCountTest.insert_datacCsB|jj}t|jj|jj|jj}|| }t ||j dS)N) r&rrcrrZorder_byrr'Zfetchallr r%)selfr*r+srowsrrr test_basicBszRowCountTest.test_basic statementupdatedeleter(r close_firstFc Cs|jj}|jj}|jr6|||dkddi}n|jr\|||dkddi}nx|jr||dddddd ddd d ddg}nB|j rt |jj |jj|jjdk}||}| n| |r| |jd kstdS) NrrZznone 1Xrznone 2znone 3))r&rr-rr3r'wherer4r(rrallfailcloserowcountAssertionError)r.r*r2r5r+rrr/rrr$test_non_rowcount_scenarios_no_raiseKsB      z1RowCountTest.test_non_rowcount_scenarios_no_raisecCs@|jj}|jj}|||dkddi}|jdks|jj}|jj}|||dkddi}t|jddS)Nrrr<) r&rr-rr'r3r=r rArErrrtest_update_rowcount2sz"RowCountTest.test_update_rowcount2implicit_returningdmlc Cs|r|jj}n6tdttdtdddtdtdtdtd dd }|jj}|j rz| |d kj |jjd d  }n&|j r| |d k }n|||}t|jddS)znote this test should succeed for all RETURNING backends as of 2.0. In Idf28379f8705e403a3c6a937f6a798a042ef2540 we changed rowcount to use len(rows) when we have implicit returning rrFTrrrrr)rHrr6)rr<N)r&rrrrrrr-rr3r=valuesZreturn_defaultsr4r?r'r rA)r.r*rHrIr+rstmtrCrrr+test_update_delete_rowcount_return_defaultss>     z8RowCountTest.test_update_delete_rowcount_return_defaultscCs|d}t|jddSNz8update employees set department='Z' where department='C'r<)Zexec_driver_sqlr rAr.r*resultrrrtest_raw_sql_rowcountsz"RowCountTest.test_raw_sql_rowcountcCs|td}t|jddSrM)r'r r rArNrrrtest_text_rowcountszRowCountTest.test_text_rowcountcCs8|jj}|jj}|||dk}t|jddS)Nrr<) r&rr-rr'r4r=r rArErrrtest_delete_rowcounts z!RowCountTest.test_delete_rowcountcCsX|jj}||jjtdkjdd}||ddiddiddig}t |j ddS)Nemp_namer)rrr nonexistent) r&rr3r=r-rrrJr'r rAr.r*r+rKrCrrrtest_multi_update_rowcounts z'RowCountTest.test_multi_update_rowcountcCsP|jj}||jjtdk}||ddiddiddig}t|j ddS)NrSrrrTrU) r&rr4r=r-rrr'r rArVrrrtest_multi_delete_rowcounts z'RowCountTest.test_multi_delete_rowcountN)__name__ __module__ __qualname____doc__ __requires__Z __backend__ classmethodrr,r1r Z variationrDrFrGrequiresZupdate_returningZdelete_returningrLrPrQrRZsane_multi_rowcountrWrXrrrrr s8    )     0  r N)Z sqlalchemyrrrrrrrr r Zsqlalchemy.testingr r Z TablesTestr rrrr s