Commits

jpel...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed e6a5447

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

  • Participants
  • Parent commits 3ae9f6f
  • Branches multiple-db-support

Comments (0)

Files changed (6)

File 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:

File 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:

File 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:

File 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:

File 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:

File 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: