Skip to content

Commit 6784383

Browse files
authored
Fixed #28498 -- Fixed test database creation with cx_Oracle 6.
1 parent a493424 commit 6784383

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

django/db/backends/oracle/creation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def _create_test_db(self, verbosity=1, autoclobber=False, keepdb=False):
9797
print("Tests cancelled.")
9898
sys.exit(1)
9999

100+
# Cursor must be closed before closing connection.
101+
cursor.close()
100102
self._maindb_connection.close() # done with main user -- test user and tablespaces created
101103
self._switch_to_test_user(parameters)
102104
return self.connection.settings_dict['NAME']
@@ -182,6 +184,8 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
182184
if verbosity >= 1:
183185
print('Destroying test database tables...')
184186
self._execute_test_db_destruction(cursor, parameters, verbosity)
187+
# Cursor must be closed before closing connection.
188+
cursor.close()
185189
self._maindb_connection.close()
186190

187191
def _execute_test_db_creation(self, cursor, parameters, verbosity, keepdb=False):

docs/releases/1.11.5.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Bugfixes
1111

1212
* Fixed GEOS version parsing if the version has a commit hash at the end (new
1313
in GEOS 3.6.2) (:ticket:`28441`).
14+
15+
* Fixed test database creation with ``cx_Oracle`` 6 (:ticket:`28498`).

tests/select_for_update/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def start_blocking_transaction(self):
5656

5757
def end_blocking_transaction(self):
5858
# Roll back the blocking transaction.
59+
self.cursor.close()
5960
self.new_connection.rollback()
6061
self.new_connection.set_autocommit(True)
6162

@@ -370,7 +371,10 @@ def raw(status):
370371
finally:
371372
# This method is run in a separate thread. It uses its own
372373
# database connection. Close it without waiting for the GC.
373-
connection.close()
374+
# Connection cannot be closed on Oracle because cursor is still
375+
# open.
376+
if connection.vendor != 'oracle':
377+
connection.close()
374378

375379
status = []
376380
thread = threading.Thread(target=raw, kwargs={'status': status})

0 commit comments

Comments
 (0)