Commits

Anonymous committed e6a5447

[multi-db] For all backends: commit only when a connection exists.

Comments (0)

Files changed (6)

django/db/backends/ado_mssql/base.py

         return cursor
 
     def _commit(self):
-        return self.connection.commit()
+        if self.connection:
+            return self.connection.commit()
 
     def _rollback(self):
         if self.connection:

django/db/backends/mysql/base.py

         return cursor
 
     def _commit(self):
-        self.connection.commit()
+        if self.connection:
+            self.connection.commit()
 
     def _rollback(self):
         if self.connection:

django/db/backends/oracle/base.py

         return FormatStylePlaceholderCursor(self.connection)
 
     def _commit(self):
-        self.connection.commit()
+        if self.connection:
+            self.connection.commit()
 
     def _rollback(self):
         if self.connection:

django/db/backends/postgresql/base.py

         return cursor
 
     def _commit(self):
-        return self.connection.commit()
+        if self.connection:
+            return self.connection.commit()
 
     def _rollback(self):
         if self.connection:

django/db/backends/postgresql_psycopg2/base.py

         return cursor
 
     def _commit(self):
-        return self.connection.commit()
+        if self.connection:
+            return self.connection.commit()
 
     def _rollback(self):
         if self.connection:

django/db/backends/sqlite3/base.py

             return cursor
 
     def _commit(self):
-        self.connection.commit()
+        if self.connection:
+            self.connection.commit()
 
     def _rollback(self):
         if self.connection: