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:
Claude Paroz 2012-05-18 12:08:36 +02:00
parent 7495730d32
commit 7549de841c
2 changed files with 13 additions and 5 deletions

View File

@ -414,10 +414,11 @@ class BaseDatabaseFeatures(object):
def confirm(self):
"Perform manual checks of any database features that might vary between installs"
self._confirmed = True
self.supports_transactions = self._supports_transactions()
self.supports_stddev = self._supports_stddev()
self.can_introspect_foreign_keys = self._can_introspect_foreign_keys()
if not self._confirmed:
self._confirmed = True
self.supports_transactions = self._supports_transactions()
self.supports_stddev = self._supports_stddev()
self.can_introspect_foreign_keys = self._can_introspect_foreign_keys()
def _supports_transactions(self):
"Confirm support for transactions"
@ -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"

View File

@ -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()