Permalink
Browse files

Fixed #28498 -- Fixed test database creation with cx_Oracle 6.

  • Loading branch information...
1 parent a493424 commit 6784383e93d582f43f8cb5f7647a05645cbb339b @felixxm felixxm committed on GitHub Aug 16, 2017
Showing with 11 additions and 1 deletion.
  1. +4 −0 django/db/backends/oracle/creation.py
  2. +2 −0 docs/releases/1.11.5.txt
  3. +5 −1 tests/select_for_update/tests.py
@@ -97,6 +97,8 @@ def _create_test_db(self, verbosity=1, autoclobber=False, keepdb=False):
print("Tests cancelled.")
sys.exit(1)
+ # Cursor must be closed before closing connection.
+ cursor.close()
self._maindb_connection.close() # done with main user -- test user and tablespaces created
self._switch_to_test_user(parameters)
return self.connection.settings_dict['NAME']
@@ -182,6 +184,8 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
if verbosity >= 1:
print('Destroying test database tables...')
self._execute_test_db_destruction(cursor, parameters, verbosity)
+ # Cursor must be closed before closing connection.
+ cursor.close()
self._maindb_connection.close()
def _execute_test_db_creation(self, cursor, parameters, verbosity, keepdb=False):
View
@@ -11,3 +11,5 @@ Bugfixes
* Fixed GEOS version parsing if the version has a commit hash at the end (new
in GEOS 3.6.2) (:ticket:`28441`).
+
+* Fixed test database creation with ``cx_Oracle`` 6 (:ticket:`28498`).
@@ -56,6 +56,7 @@ def start_blocking_transaction(self):
def end_blocking_transaction(self):
# Roll back the blocking transaction.
+ self.cursor.close()
self.new_connection.rollback()
self.new_connection.set_autocommit(True)
@@ -370,7 +371,10 @@ def raw(status):
finally:
# This method is run in a separate thread. It uses its own
# database connection. Close it without waiting for the GC.
- connection.close()
+ # Connection cannot be closed on Oracle because cursor is still
+ # open.
+ if connection.vendor != 'oracle':
+ connection.close()
status = []
thread = threading.Thread(target=raw, kwargs={'status': status})

0 comments on commit 6784383

Please sign in to comment.