mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.9.x] Refs #12118 -- Allowed "mode=memory" in SQLite test database names.
Backport of 3543fec3b7 from master
This commit is contained in:
committed by
Tim Graham
parent
6bc8bdf55a
commit
6f653f759a
@@ -11,14 +11,16 @@ class DatabaseCreation(BaseDatabaseCreation):
|
||||
|
||||
def _get_test_db_name(self):
|
||||
test_database_name = self.connection.settings_dict['TEST']['NAME']
|
||||
can_share_in_memory_db = self.connection.features.can_share_in_memory_db
|
||||
if test_database_name and test_database_name != ':memory:':
|
||||
if 'mode=memory' in test_database_name:
|
||||
if 'mode=memory' in test_database_name and not can_share_in_memory_db:
|
||||
raise ImproperlyConfigured(
|
||||
"Using `mode=memory` parameter in the database name is not allowed, "
|
||||
"Using a shared memory database with `mode=memory` in the "
|
||||
"database name is not supported in your environment, "
|
||||
"use `:memory:` instead."
|
||||
)
|
||||
return test_database_name
|
||||
if self.connection.features.can_share_in_memory_db:
|
||||
if can_share_in_memory_db:
|
||||
return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
|
||||
return ':memory:'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user