# HG changeset patch
# User Brodie Rao <brodie@bitheap.org>
# Date 1305680847 25200
# Branch releases/1.3.X
# Node ID 449a8f9da389a7a6642d8bb2c98825df8a02c90e
# Parent 6709ee4d9f37ada03979e5bd1d7b1fc737eef936
db: properly detect transaction support when using psycopg2 in autocommit mode
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
a
|
b
|
class BaseDatabaseFeatures(object):
|
352 | 352 | |
353 | 353 | def _supports_transactions(self): |
354 | 354 | "Confirm support for transactions" |
355 | | cursor = self.connection.cursor() |
356 | | cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') |
357 | | self.connection._commit() |
358 | | cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') |
359 | | self.connection._rollback() |
360 | | cursor.execute('SELECT COUNT(X) FROM ROLLBACK_TEST') |
361 | | count, = cursor.fetchone() |
362 | | cursor.execute('DROP TABLE ROLLBACK_TEST') |
363 | | self.connection._commit() |
364 | | return count == 0 |
| 355 | managed = self.connection.is_managed() |
| 356 | self.connection.enter_transaction_management() |
| 357 | self.connection.managed(True) |
| 358 | try: |
| 359 | cursor = self.connection.cursor() |
| 360 | cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') |
| 361 | self.connection.commit() |
| 362 | cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') |
| 363 | self.connection.rollback() |
| 364 | cursor.execute('SELECT COUNT(X) FROM ROLLBACK_TEST') |
| 365 | count, = cursor.fetchone() |
| 366 | cursor.execute('DROP TABLE ROLLBACK_TEST') |
| 367 | self.connection.commit() |
| 368 | return count == 0 |
| 369 | finally: |
| 370 | self.connection.managed(managed) |
| 371 | self.connection.leave_transaction_management() |
365 | 372 | |
366 | 373 | def _supports_stddev(self): |
367 | 374 | "Confirm support for STDDEV and related stats functions" |