Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #18334 -- Fixed detection of supports_stddev backend feature.

Thanks to Michael Manfre for the report and Anssi Kääriäinen for the
review.
  • Loading branch information...
commit 7549de841c6e0d18822af047763f5e3211539be8 1 parent 7495730
Claude Paroz claudep authored
12 django/db/backends/__init__.py
View
@@ -414,10 +414,11 @@ def __init__(self, connection):
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 StdDevPop(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"
6 tests/regressiontests/backends/tests.py
View
@@ -397,6 +397,12 @@ def test_database_operations_helper_class(self):
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()
Please sign in to comment.
Something went wrong with that request. Please try again.