Code

Ticket #16250: 16250-2.diff

File 16250-2.diff, 2.5 KB (added by ramiro, 3 years ago)

More invasive fix

Line 
1diff -r 7d5687126d6d django/db/backends/creation.py
2--- a/django/db/backends/creation.py    Tue Jun 14 10:45:49 2011 +0000
3+++ b/django/db/backends/creation.py    Tue Jun 14 13:34:30 2011 -0300
4@@ -247,7 +247,7 @@
5             verbosity=max(verbosity - 1, 0),
6             interactive=False,
7             database=self.connection.alias)
8-       
9+
10         # One effect of calling syncdb followed by flush is that the id of the
11         # default site may or may not be 1, depending on how the sequence was
12         # reset.  If the sites app is loaded, then we coerce it.
13@@ -346,13 +346,7 @@
14 
15     def set_autocommit(self):
16         "Make sure a connection is in autocommit mode."
17-        if hasattr(self.connection.connection, "autocommit"):
18-            if callable(self.connection.connection.autocommit):
19-                self.connection.connection.autocommit(True)
20-            else:
21-                self.connection.connection.autocommit = True
22-        elif hasattr(self.connection.connection, "set_isolation_level"):
23-            self.connection.connection.set_isolation_level(0)
24+        pass
25 
26     def sql_table_creation_suffix(self):
27         "SQL to append to the end of the test table creation statements"
28diff -r 7d5687126d6d django/db/backends/oracle/creation.py
29--- a/django/db/backends/oracle/creation.py     Tue Jun 14 10:45:49 2011 +0000
30+++ b/django/db/backends/oracle/creation.py     Tue Jun 14 13:34:30 2011 -0300
31@@ -270,3 +270,6 @@
32             settings_dict['NAME'],
33             self._test_database_user(),
34         )
35+
36+    def set_autocommit(self):
37+        self.connection.connection.autocommit = True
38diff -r 7d5687126d6d django/db/backends/postgresql_psycopg2/creation.py
39--- a/django/db/backends/postgresql_psycopg2/creation.py        Tue Jun 14 10:45:49 2011 +0000
40+++ b/django/db/backends/postgresql_psycopg2/creation.py        Tue Jun 14 13:34:30 2011 -0300
41@@ -76,3 +76,6 @@
42         else:
43             output = []
44         return output
45+
46+    def set_autocommit(self):
47+        self.connection.connection.set_isolation_level(0)
48diff -r 7d5687126d6d django/db/backends/sqlite3/creation.py
49--- a/django/db/backends/sqlite3/creation.py    Tue Jun 14 10:45:49 2011 +0000
50+++ b/django/db/backends/sqlite3/creation.py    Tue Jun 14 13:34:30 2011 -0300
51@@ -69,3 +69,6 @@
52         if test_database_name and test_database_name != ":memory:":
53             # Remove the SQLite database file
54             os.remove(test_database_name)
55+
56+    def set_autocommit(self):
57+        self.connection.connection.isolation_level = None