U a,@sddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZGdddejZGdddejZGdddejZdZdS))config)engines)fixtures)eq_) requirements)Column)Table)Integer)literal)literal_column)select)Stringc@sReZdZdZdZdZddiZeddZdd Z d d Z d d Z e j ddZdS) LastrowidTesteachT)Zimplements_get_lastrowidautoincrement_insertimplicit_returningFc CsLtd|tdtdddtdtdtd|tdtddd tdtddS) N autoinc_pkidT primary_keyZtest_needs_autoincrementdata2 manual_pkFrZ autoincrementrrr rclsmetadatareC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\testing\suite\test_insert.py define_tabless"   zLastrowidTest.define_tablescCs(||}t||jjdfdSN some dataexecuter firstrdialectZdefault_sequence_baseselftableconnrowrrr _assert_round_trip*sz LastrowidTest._assert_round_tripcCs.||jjtdd||jj|dSNr#rr%tablesrinsertdictr-r) connectionrrr test_autoincrement_on_insert4s  z*LastrowidTest.test_autoincrement_on_insertcCsB||jjtdd}|t|jjjj}t |j |fdSr. r%r1rr2r3scalarr crrinserted_primary_keyr)r5rpkrrr test_last_inserted_id;s  z#LastrowidTest.test_last_inserted_idcCsD||jjtdd}|j}|t|jjjj }t ||dSr.) r%r1rr2r3 lastrowidr8r r9rr)r)r5r<r?r=rrr test_native_lastrowid_autoincCs z+LastrowidTest.test_native_lastrowid_autoincN)__name__ __module__ __qualname__ run_deletes __backend__ __requires____engine_options__ classmethodr!r-r6r>rZdbapi_lastrowidr@rrrr rs  rc@seZdZdZdZeddZejddZ ej ddZ ej d d Z ejd d Zejd dZejddZejddZejddZdS)InsertBehaviorTestrTc Cstd|tdtdddtdtdtd|tdtddd tdtdtd |tdtdddtdtdtd td d tdttdtdtdd dS)NrrTrrrrFrincludes_defaultsx)defaulty2)type_r)rrr rr r rrrr r!QsD    z InsertBehaviorTest.define_tablesc Cstjjrtjddid}ntj}| }||j j t dd}W5QRX|j sXt|jrbt|jslt|jr|dkstdS)NrF)optionsr#r/)r returningZenabledrZtesting_enginerdbbeginr%r1rr2r3 _soft_closedAssertionErrorclosed is_insert returns_rowsfetchone)r)Zenginer+r<rrr test_autoclose_on_insertps     z+InsertBehaviorTest.test_autoclose_on_insertcCsd||jjtdd}|js$t|jr.t|js8t|j sBtt | dt | dgdS)Nr#r/r) r%r1rr2r3rUrVrWrXrYrrZkeysr)r5r<rrr +test_autoclose_on_insert_implicit_returnings     z>InsertBehaviorTest.test_autoclose_on_insert_implicit_returningcCs`||jj}|jst|jr&t||jj|jjj j dk}t t | ddS)Nr%r1rr2rUrVrWr wherer9rrlenallr]rrr test_empty_inserts   z$InsertBehaviorTest.test_empty_insertcCsh||jjiiig}|js$t|jr.t||jj|jjj j dk}t t | ddS)Nr r`r]rrr test_empty_insert_multiples   z-InsertBehaviorTest.test_empty_insert_multiplec Cs|jj}|jj}||tdddtdddtdddg||dt|jj  |jj ddg}t |j d |t|jj |jj }t |d d gdS) Nr_data1rrrdata2r data3r/Nrhri)r1rrr%r2r3 from_selectr r9rrain_rr:order_byfetchallr)r5Z src_tableZ dest_tableresultrrr test_insert_from_select_autoincs,      z2InsertBehaviorTest.test_insert_from_select_autoincc Cs||jj}|jj}||dt|jj |jj ddg}t |j d|t|jj |jj}t |gdS)Nr/rhrirj)r1rrr%r2rmr r9rrarnrr:rorprqrrr 'test_insert_from_select_autoinc_no_rowss  z:InsertBehaviorTest.test_insert_from_select_autoinc_no_rowsc Cs|jj}||tdddtdddtdddg||dt|jj d|jj  |jj ddgt |t|jj |jj d d d d d gdS) Nr_rfrgrrhr rirL)rfrkrl)r1rr%r2r3inlinermr r9rrrarnrrorpr)r5r*rrr test_insert_from_selects,       z*InsertBehaviorTest.test_insert_from_selectc Cs|jj}||tdddtdddtdddg||dt|jj d|jj  |jj ddgt |t||jj |jj d d d d d gdS)Nr_rfrgrrhr rirL)r_rfrL)rrhrLrx)rhrLrx)r rirLrx)rirLrx)r1rJr%r2r3rurmr r9rrrarnrrorprvrrr %test_insert_from_select_with_defaults s6      z8InsertBehaviorTest.test_insert_from_select_with_defaultsN)rArBrCrDrErHr!rrr[rRr^Z empty_insertsrdZempty_inserts_executemanyreZinsert_from_selectrsrtrwr{rrrr rIMs(        rIc@sZeZdZdZdZdZddiZddZeddZ e j d d Z d d Z d dZddZdS) ReturningTestr)rRrTrcCs(||}t||jjdfdSr"r$r(rrr r-7sz ReturningTest._assert_round_tripc Cs(td|tdtdddtdtddS)NrrTrrrrrrrr r!As zReturningTest.define_tablescCsT|jj}|||jjtdd}|d}| t |jj}t ||dSNr#r/ r1rr%r2rRr9rr3r&r8r rr)r5r*r<r=Z fetched_pkrrr %test_explicit_returning_pk_autocommitLs z3ReturningTest.test_explicit_returning_pk_autocommitcCsT|jj}|||jjtdd}|d}| t |jj}t ||dSr}rrrrr (test_explicit_returning_pk_no_autocommitVs z6ReturningTest.test_explicit_returning_pk_no_autocommitcCs.||jjtdd||jj|dSr.r0r4rrr /test_autoincrement_on_insert_implicit_returning_s  z=ReturningTest.test_autoincrement_on_insert_implicit_returningcCsB||jjtdd}|t|jjjj}t |j |fdSr.r7r;rrr (test_last_inserted_id_implicit_returningfs  z6ReturningTest.test_last_inserted_id_implicit_returningN)rArBrCZrun_create_tablesrFrErGr-rHr!rZfetch_rows_post_commitrrrrrrrr r|0s    r|)rrIr|N)rrrZ assertionsrrZschemarrr r r r rZ TablesTestrrIr|__all__rrrr s            >d?