Ticket #17760: 17760-2.diff
File 17760-2.diff, 7.0 KB (added by , 13 years ago) |
---|
-
django/contrib/gis/db/backends/spatialite/creation.py
diff --git a/django/contrib/gis/db/backends/spatialite/creation.py b/django/contrib/gis/db/backends/spatialite/creation.py index 33b6f95..5c97113 100644
a b class SpatiaLiteCreation(DatabaseCreation): 31 31 self.connection.close() 32 32 self.connection.settings_dict["NAME"] = test_database_name 33 33 34 # Confirm the feature set of the test database35 self.connection.features.confirm()36 37 34 # Need to load the SpatiaLite initialization SQL before running `syncdb`. 38 35 self.load_spatialite_sql() 39 36 -
django/db/backends/__init__.py
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 7674f5c..4a15e40 100644
a b from django.conf import settings 10 10 from django.db import DEFAULT_DB_ALIAS 11 11 from django.db.backends import util 12 12 from django.db.transaction import TransactionManagementError 13 from django.utils.functional import cached_property 13 14 from django.utils.importlib import import_module 14 15 from django.utils.timezone import is_aware 15 16 … … class BaseDatabaseFeatures(object): 399 400 # in the SQL standard. 400 401 supports_tablespaces = False 401 402 402 # Features that need to be confirmed at runtime 403 # Cache whether the confirmation has been performed. 404 _confirmed = False 405 supports_transactions = None 406 supports_stddev = None 407 can_introspect_foreign_keys = None 403 # Confirm support for introspected foreign keys 404 # Every database can do this reliably, except MySQL, 405 # which can't do it for MyISAM tables 406 can_introspect_foreign_keys = True 408 407 409 408 # Support for the DISTINCT ON clause 410 409 can_distinct_on_fields = False … … class BaseDatabaseFeatures(object): 412 411 def __init__(self, connection): 413 412 self.connection = connection 414 413 415 def confirm(self): 416 "Perform manual checks of any database features that might vary between installs" 417 self._confirmed = True 418 self.supports_transactions = self._supports_transactions() 419 self.supports_stddev = self._supports_stddev() 420 self.can_introspect_foreign_keys = self._can_introspect_foreign_keys() 421 422 def _supports_transactions(self): 414 @cached_property 415 def supports_transactions(self): 423 416 "Confirm support for transactions" 424 417 cursor = self.connection.cursor() 425 418 cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') … … class BaseDatabaseFeatures(object): 432 425 self.connection._commit() 433 426 return count == 0 434 427 435 def _supports_stddev(self): 428 @cached_property 429 def supports_stddev(self): 436 430 "Confirm support for STDDEV and related stats functions" 437 431 class StdDevPop(object): 438 432 sql_function = 'STDDEV_POP' … … class BaseDatabaseFeatures(object): 440 434 try: 441 435 self.connection.ops.check_aggregate_support(StdDevPop()) 442 436 except NotImplementedError: 443 self.supports_stddev = False 444 445 def _can_introspect_foreign_keys(self): 446 "Confirm support for introspected foreign keys" 447 # Every database can do this reliably, except MySQL, 448 # which can't do it for MyISAM tables 437 return False 449 438 return True 450 439 451 440 -
django/db/backends/creation.py
diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 2db0acc..a5ed311 100644
a b class BaseDatabaseCreation(object): 258 258 self.connection.close() 259 259 self.connection.settings_dict["NAME"] = test_database_name 260 260 261 # Confirm the feature set of the test database262 self.connection.features.confirm()263 264 261 # Report syncdb messages at one level lower than that requested. 265 262 # This ensures we don't get flooded with messages during testing 266 263 # (unless you really ask to be flooded) -
django/db/backends/mysql/base.py
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 830808b..92e04f0 100644
a b from django.db.backends.mysql.client import DatabaseClient 32 32 from django.db.backends.mysql.creation import DatabaseCreation 33 33 from django.db.backends.mysql.introspection import DatabaseIntrospection 34 34 from django.db.backends.mysql.validation import DatabaseValidation 35 from django.utils.functional import cached_property 35 36 from django.utils.safestring import SafeString, SafeUnicode 36 37 from django.utils.timezone import is_aware, is_naive, utc 37 38 … … class DatabaseFeatures(BaseDatabaseFeatures): 152 153 153 154 def __init__(self, connection): 154 155 super(DatabaseFeatures, self).__init__(connection) 155 self._storage_engine = None156 156 157 @cached_property 157 158 def _mysql_storage_engine(self): 158 159 "Internal method used in Django tests. Don't rely on this from your code" 159 if self._storage_engine is None: 160 cursor = self.connection.cursor() 161 cursor.execute('CREATE TABLE INTROSPECT_TEST (X INT)') 162 # This command is MySQL specific; the second column 163 # will tell you the default table type of the created 164 # table. Since all Django's test tables will have the same 165 # table type, that's enough to evaluate the feature. 166 cursor.execute("SHOW TABLE STATUS WHERE Name='INTROSPECT_TEST'") 167 result = cursor.fetchone() 168 cursor.execute('DROP TABLE INTROSPECT_TEST') 169 self._storage_engine = result[1] 170 return self._storage_engine 171 172 def _can_introspect_foreign_keys(self): 160 cursor = self.connection.cursor() 161 cursor.execute('CREATE TABLE INTROSPECT_TEST (X INT)') 162 # This command is MySQL specific; the second column 163 # will tell you the default table type of the created 164 # table. Since all Django's test tables will have the same 165 # table type, that's enough to evaluate the feature. 166 cursor.execute("SHOW TABLE STATUS WHERE Name='INTROSPECT_TEST'") 167 result = cursor.fetchone() 168 cursor.execute('DROP TABLE INTROSPECT_TEST') 169 return result[1] 170 171 @cached_property 172 def can_introspect_foreign_keys(self): 173 173 "Confirm support for introspected foreign keys" 174 174 return self._mysql_storage_engine() != 'MyISAM' 175 175 -
tests/regressiontests/transactions_regress/tests.py
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py index 5972263..abd7a4c 100644
a b class SavepointTest(TransactionTestCase): 208 208 work() 209 209 210 210 @skipIf(connection.vendor == 'mysql' and \ 211 connection.features._mysql_storage_engine ()== 'MyISAM',211 connection.features._mysql_storage_engine == 'MyISAM', 212 212 "MyISAM MySQL storage engine doesn't support savepoints") 213 213 @skipUnlessDBFeature('uses_savepoints') 214 214 def test_savepoint_rollback(self):