Fixed #25357 -- Database deduplication on Oracle.

In order to reuse another database, Django must use set_as_test_mirror.
This commit is contained in:
Aymeric Augustin 2015-09-05 20:00:33 +02:00
parent 5ace1887f2
commit 79c3f226dd
1 changed files with 8 additions and 7 deletions

View File

@ -377,22 +377,23 @@ def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, **kwa
mirrors = [] mirrors = []
for signature, (db_name, aliases) in test_databases.items(): for signature, (db_name, aliases) in test_databases.items():
test_db_name = None first_alias = None
# Actually create the database for the first connection # Actually create the database for the first connection
for alias in aliases: for alias in aliases:
connection = connections[alias] connection = connections[alias]
if test_db_name is None: old_names.append((connection, db_name, first_alias is None))
test_db_name = connection.creation.create_test_db(
if first_alias is None:
first_alias = alias
connection.creation.create_test_db(
verbosity, verbosity,
autoclobber=not interactive, autoclobber=not interactive,
keepdb=keepdb, keepdb=keepdb,
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True), serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
) )
destroy = True
else: else:
connection.settings_dict['NAME'] = test_db_name connections[alias].creation.set_as_test_mirror(
destroy = False connections[first_alias].settings_dict)
old_names.append((connection, db_name, destroy))
for alias, mirror_alias in mirrored_aliases.items(): for alias, mirror_alias in mirrored_aliases.items():
mirrors.append((alias, connections[alias].settings_dict['NAME'])) mirrors.append((alias, connections[alias].settings_dict['NAME']))