diff --git a/AUTHORS b/AUTHORS index 7a787ec74f..4a027fdd6e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -112,6 +112,7 @@ answer newbie questions, and generally made Django that much better: Garth Kidd kilian Sune Kirkeby + Bastian Kleineidam Cameron Knight (ckknight) Meir Kriheli Bruce Kroeze diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 9eaa5625d9..8dcb98ce61 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -76,10 +76,11 @@ class DatabaseWrapper(local): return cursor def _commit(self): - return self.connection.commit() + if self.connection is not None: + return self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: return self.connection.rollback() def close(self): diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 4ccb1fe564..4bd87518e8 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -108,10 +108,11 @@ class DatabaseWrapper(local): return cursor def _commit(self): - self.connection.commit() + if self.connection is not None: + self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: try: self.connection.rollback() except Database.NotSupportedError: diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 229e203ca1..d52ae33c2e 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -43,10 +43,11 @@ class DatabaseWrapper(local): return FormatStylePlaceholderCursor(self.connection) def _commit(self): - self.connection.commit() + if self.connection is not None: + self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: try: self.connection.rollback() except Database.NotSupportedError: diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 89695b0c4b..54be422ae2 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -92,10 +92,11 @@ class DatabaseWrapper(local): return cursor def _commit(self): - return self.connection.commit() + if self.connection is not None: + return self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: return self.connection.rollback() def close(self): diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 9b319ad3c7..e4724e46fb 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -60,10 +60,11 @@ class DatabaseWrapper(local): return cursor def _commit(self): - return self.connection.commit() + if self.connection is not None: + return self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: return self.connection.rollback() def close(self): diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index ce343e189e..4b8a1c64a8 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -67,10 +67,11 @@ class DatabaseWrapper(local): return cursor def _commit(self): - self.connection.commit() + if self.connection is not None: + self.connection.commit() def _rollback(self): - if self.connection: + if self.connection is not None: self.connection.rollback() def close(self):