Fixed #7751 -- Added check to allow for the fact that autocommit can be a property, rather than a function on certain database backends. Thanks to Leo Soto for the fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7940 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2008-07-17 13:24:05 +00:00
parent 431206a252
commit 1107e6b479
1 changed files with 4 additions and 1 deletions

View File

@ -74,7 +74,10 @@ def teardown_test_environment():
def _set_autocommit(connection): def _set_autocommit(connection):
"Make sure a connection is in autocommit mode." "Make sure a connection is in autocommit mode."
if hasattr(connection.connection, "autocommit"): if hasattr(connection.connection, "autocommit"):
connection.connection.autocommit(True) if callable(connection.connection.autocommit):
connection.connection.autocommit(True)
else:
connection.connection.autocommit = True
elif hasattr(connection.connection, "set_isolation_level"): elif hasattr(connection.connection, "set_isolation_level"):
connection.connection.set_isolation_level(0) connection.connection.set_isolation_level(0)