mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #28584 -- Removed unused DatabaseFeatures.can_share_in_memory_db.
This commit is contained in:
parent
a2626cb3fe
commit
d0c761d3f8
@ -153,9 +153,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
'for controlling thread shareability.',
|
'for controlling thread shareability.',
|
||||||
RuntimeWarning
|
RuntimeWarning
|
||||||
)
|
)
|
||||||
kwargs.update({'check_same_thread': False})
|
kwargs.update({'check_same_thread': False, 'uri': True})
|
||||||
if self.features.can_share_in_memory_db:
|
|
||||||
kwargs.update({'uri': True})
|
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_new_connection(self, conn_params):
|
def get_new_connection(self, conn_params):
|
||||||
|
@ -2,7 +2,6 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.db.backends.base.creation import BaseDatabaseCreation
|
from django.db.backends.base.creation import BaseDatabaseCreation
|
||||||
|
|
||||||
|
|
||||||
@ -14,18 +13,10 @@ class DatabaseCreation(BaseDatabaseCreation):
|
|||||||
|
|
||||||
def _get_test_db_name(self):
|
def _get_test_db_name(self):
|
||||||
test_database_name = self.connection.settings_dict['TEST']['NAME']
|
test_database_name = self.connection.settings_dict['TEST']['NAME']
|
||||||
can_share_in_memory_db = self.connection.features.can_share_in_memory_db
|
|
||||||
if not test_database_name:
|
if not test_database_name:
|
||||||
test_database_name = ':memory:'
|
test_database_name = ':memory:'
|
||||||
if can_share_in_memory_db:
|
if test_database_name == ':memory:':
|
||||||
if test_database_name == ':memory:':
|
return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
|
||||||
return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
|
|
||||||
elif 'mode=memory' in test_database_name:
|
|
||||||
raise ImproperlyConfigured(
|
|
||||||
"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
|
return test_database_name
|
||||||
|
|
||||||
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
|
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
|
||||||
|
@ -30,7 +30,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
|||||||
supports_cast_with_precision = False
|
supports_cast_with_precision = False
|
||||||
uses_savepoints = True
|
uses_savepoints = True
|
||||||
can_release_savepoints = True
|
can_release_savepoints = True
|
||||||
can_share_in_memory_db = True
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def supports_stddev(self):
|
def supports_stddev(self):
|
||||||
|
@ -2,12 +2,9 @@ import re
|
|||||||
import threading
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.models import Avg, StdDev, Sum, Variance
|
from django.db.models import Avg, StdDev, Sum, Variance
|
||||||
from django.test import (
|
from django.test import TestCase, TransactionTestCase, override_settings
|
||||||
TestCase, TransactionTestCase, override_settings, skipUnlessDBFeature,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..models import Item, Object, Square
|
from ..models import Item, Object, Square
|
||||||
|
|
||||||
@ -56,19 +53,8 @@ class Tests(TestCase):
|
|||||||
'NAME': 'file:memorydb_test?mode=memory&cache=shared',
|
'NAME': 'file:memorydb_test?mode=memory&cache=shared',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrapper = DatabaseWrapper(settings_dict)
|
creation = DatabaseWrapper(settings_dict).creation
|
||||||
creation = wrapper.creation
|
self.assertEqual(creation._get_test_db_name(), creation.connection.settings_dict['TEST']['NAME'])
|
||||||
if creation.connection.features.can_share_in_memory_db:
|
|
||||||
expected = creation.connection.settings_dict['TEST']['NAME']
|
|
||||||
self.assertEqual(creation._get_test_db_name(), expected)
|
|
||||||
else:
|
|
||||||
msg = (
|
|
||||||
"Using a shared memory database with `mode=memory` in the "
|
|
||||||
"database name is not supported in your environment, "
|
|
||||||
"use `:memory:` instead."
|
|
||||||
)
|
|
||||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
|
||||||
creation._get_test_db_name()
|
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == 'sqlite', 'Test only for SQLite')
|
@unittest.skipUnless(connection.vendor == 'sqlite', 'Test only for SQLite')
|
||||||
@ -124,7 +110,6 @@ class EscapingChecksDebug(EscapingChecks):
|
|||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
|
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
|
||||||
@skipUnlessDBFeature('can_share_in_memory_db')
|
|
||||||
class ThreadSharing(TransactionTestCase):
|
class ThreadSharing(TransactionTestCase):
|
||||||
available_apps = ['backends']
|
available_apps = ['backends']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user