mirror of
https://github.com/django/django.git
synced 2025-03-03 13:34:26 +00:00
Fixed #18334 -- Fixed detection of supports_stddev backend feature.
Thanks to Michael Manfre for the report and Anssi Kääriäinen for the review.
This commit is contained in:
parent
7495730d32
commit
7549de841c
@ -414,10 +414,11 @@ class BaseDatabaseFeatures(object):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
"Perform manual checks of any database features that might vary between installs"
|
"Perform manual checks of any database features that might vary between installs"
|
||||||
self._confirmed = True
|
if not self._confirmed:
|
||||||
self.supports_transactions = self._supports_transactions()
|
self._confirmed = True
|
||||||
self.supports_stddev = self._supports_stddev()
|
self.supports_transactions = self._supports_transactions()
|
||||||
self.can_introspect_foreign_keys = self._can_introspect_foreign_keys()
|
self.supports_stddev = self._supports_stddev()
|
||||||
|
self.can_introspect_foreign_keys = self._can_introspect_foreign_keys()
|
||||||
|
|
||||||
def _supports_transactions(self):
|
def _supports_transactions(self):
|
||||||
"Confirm support for transactions"
|
"Confirm support for transactions"
|
||||||
@ -439,8 +440,9 @@ class BaseDatabaseFeatures(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.connection.ops.check_aggregate_support(StdDevPop())
|
self.connection.ops.check_aggregate_support(StdDevPop())
|
||||||
|
return True
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
self.supports_stddev = False
|
return False
|
||||||
|
|
||||||
def _can_introspect_foreign_keys(self):
|
def _can_introspect_foreign_keys(self):
|
||||||
"Confirm support for introspected foreign keys"
|
"Confirm support for introspected foreign keys"
|
||||||
|
@ -397,6 +397,12 @@ class BackendTestCase(TestCase):
|
|||||||
self.assertTrue(hasattr(connection.ops, 'connection'))
|
self.assertTrue(hasattr(connection.ops, 'connection'))
|
||||||
self.assertEqual(connection, connection.ops.connection)
|
self.assertEqual(connection, connection.ops.connection)
|
||||||
|
|
||||||
|
def test_supports_needed_confirm(self):
|
||||||
|
connection.features.confirm()
|
||||||
|
self.assertIn(connection.features.supports_transactions, (True, False))
|
||||||
|
self.assertIn(connection.features.supports_stddev, (True, False))
|
||||||
|
self.assertIn(connection.features.can_introspect_foreign_keys, (True, False))
|
||||||
|
|
||||||
def test_duplicate_table_error(self):
|
def test_duplicate_table_error(self):
|
||||||
""" Test that creating an existing table returns a DatabaseError """
|
""" Test that creating an existing table returns a DatabaseError """
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user