Menu

#423 [python] Insert values success after rollback when set_autocommit(False)

open
nobody
None
5
2013-02-24
2013-02-24
Jira Trac
No

[python] Insert values success after rollback when set_autocommit(False)
Test Case: http://svn.cubrid.org/cubridapis/python/branches/RB-9.1.0/tests2/python/_12_autocommit/test_auocommit_01.py

Test Build: 9.1.0.0203
Test OS: Linux and windows
python driver: 9.1.0.0001

Test codes:
{code}
def test_01autocommit(self):
xddl1 = drop table if exists autocommit_t
self.cur.execute(xddl1)
ddl1 = create table autocommit_t (nameid int primary key ,age int,name VARCHAR(40))
self.cur.execute(ddl1)
self.con.set_autocommit(False)
self.assertEqual(self.con.get_autocommit(), False, autocommit is off)

self.cur.execute(insert into autocommit_t(name,nameid,age) values ('Mike',1,30),('John',2,28),('Bill',3,45) )
self.con.rollback()
self.cur.execute(select * from autocommit_t)
rows = self.cur.fetchall()
print \n
print len(rows)
self.assertEqual(len(rows), 0, 0 lines affected)
self.con.commit()
rows = self.cur.fetchall()
print len(rows)
self.assertEqual(len(rows), 0, 0 lines affected)
{code}

Test Result:
{noformat}
FAIL

======================================================================
FAIL: test_01autocommit (__main__.AutocommitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File python\_12_autocommit\test_auocommit_01.py, line 50, in test_01autocommit
self.assertEqual(len(rows), 0, 0 lines affected)
AssertionError: 0 lines affected

----------------------------------------------------------------------
Ran 1 test in 0.067s

FAILED (failures=1)
{noformat}

After rollback, the result count is 3

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.