Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: Python-Aprium
-
Fix Version/s: None
-
Component/s: Python Driver
-
Labels:
-
Environment:
Windows and Linux
Description
[Python] set autocommit failed using "self.con.set_autocommit('OFF') "
Test Build: 9.1.0.0203
Test OS: Linux and windows
python driver: 9.1.0.0001
Test codes:
def test_03errorRollback(self):
print "\nset_autocommit is not correct "
self.con.set_autocommit(False)
self.assertEqual(self.con.get_autocommit(), False, "autocommit is off")
self.con.set_autocommit('ON')
self.assertEqual(self.con.get_autocommit(), True, "autocommit is ON")
self.con.set_autocommit('OFF')
self.assertEqual(self.con.get_autocommit(), False, "autocommit is off")
Test Result:
======================================================================
FAIL: test_03errorRollback (__main__.AutocommitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "python\_12_autocommit\test_auocommit_01.py", line 87, in test_03errorRollback
self.assertEqual(self.con.get_autocommit(), False, "autocommit is off")
AssertionError: autocommit is off
----------------------------------------------------------------------
self.con.set_autocommit('ON') can set autocommit to True.
But self.con.set_autocommit('OFF') can not set autocommit to False.

Analysis:
The set_autocommit() allows the argument to be boolean. So, the below call can work:
set_autocommit(True)
set_autocommit(False)
If the argument is a string, it's corresponding to boolean True.
The above logic is the same as the set_autocommit() in Mysql Python driver.
However, there is not the specification about the arguments of set_autocommit() in PEP-249
My solution:
Because the boolean data type is availabe in Python, so I think it's more reasonable to supply the boolean type for set_autocommit().
Raise error if the parameter is not a boolean value.