Skip to content

Commit 498d32f

Browse files
Alexjwhitlock
Alex
authored andcommitted
Null out connection cache on backend objects
1 parent ede3a17 commit 498d32f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: django_nose/runner.py

+5
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ def _should_create_database(connection):
437437

438438
# Notice whether the DB exists, and create it if it doesn't:
439439
try:
440+
# Connections are cached by some backends, if other code has connected
441+
# to the database previously under a different database name the
442+
# cached connection will be used and no exception will be raised.
443+
# Setting to null here solves that problem.
444+
connection.connection = None
440445
connection.cursor()
441446
except Exception: # TODO: Be more discerning but still DB agnostic.
442447
return True

0 commit comments

Comments
 (0)