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,6 +414,7 @@ class BaseDatabaseFeatures(object):
|
|||
|
||||
def confirm(self):
|
||||
"Perform manual checks of any database features that might vary between installs"
|
||||
if not self._confirmed:
|
||||
self._confirmed = True
|
||||
self.supports_transactions = self._supports_transactions()
|
||||
self.supports_stddev = self._supports_stddev()
|
||||
|
@ -439,8 +440,9 @@ class BaseDatabaseFeatures(object):
|
|||
|
||||
try:
|
||||
self.connection.ops.check_aggregate_support(StdDevPop())
|
||||
return True
|
||||
except NotImplementedError:
|
||||
self.supports_stddev = False
|
||||
return False
|
||||
|
||||
def _can_introspect_foreign_keys(self):
|
||||
"Confirm support for introspected foreign keys"
|
||||
|
|
|
@ -397,6 +397,12 @@ class BackendTestCase(TestCase):
|
|||
self.assertTrue(hasattr(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):
|
||||
""" Test that creating an existing table returns a DatabaseError """
|
||||
cursor = connection.cursor()
|
||||
|
|
Loading…
Reference in New Issue