#NEWLINE# @ skipUnlessDBFeature ( 'supports_transactions' ) #NEWLINE# def test_reuse_cursor_reference( self ) : #NEWLINE# #INDENT# '\n        Make sure transaction closure is enforced even when the queries are performed\n        through a single cursor reference retrieved in the beginning\n        (this is to show why it is wrong to set the transaction dirty only when a cursor\n        is fetched from the connection).\n        ' #NEWLINE# @ commit_on_success #NEWLINE# def reuse_cursor_ref( ) : #NEWLINE# #INDENT# '\n            Fetch a cursor, perform an query, rollback to close the transaction,\n            then write a record (in a new transaction) using the same cursor object\n            (reference). All this under commit_on_success, so the second insert should\n            be committed.\n            ' #NEWLINE# cursor = connection . cursor ( ) #NEWLINE# cursor . execute ( 'INSERT into transactions_regress_mod (fld) values (2)' ) #NEWLINE# transaction . rollback ( ) #NEWLINE# cursor . execute ( 'INSERT into transactions_regress_mod (fld) values (2)' ) #NEWLINE# #UNINDENT# reuse_cursor_ref ( ) #NEWLINE# transaction . rollback ( ) #NEWLINE# self . assertEqual ( Mod . objects . count ( ) , 1 ) #NEWLINE# obj = Mod . objects . all ( ) [ 0 ] #NEWLINE# self . assertEqual ( self . fld , 2 )