Ticket #17760: 17760.diff
File 17760.diff, 6.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..57a550b 100644
a b class BaseDatabaseFeatures(object): 399 399 # in the SQL standard. 400 400 supports_tablespaces = False 401 401 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 402 # Confirm support for introspected foreign keys 403 # Every database can do this reliably, except MySQL, 404 # which can't do it for MyISAM tables 405 can_introspect_foreign_keys = True 408 406 409 407 # Support for the DISTINCT ON clause 410 408 can_distinct_on_fields = False 411 409 412 410 def __init__(self, connection): 413 411 self.connection = connection 412 # Cached properties 413 self._supports_transactions = None 414 self._supports_stddev = None 414 415 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): 416 @property 417 def supports_transactions(self): 423 418 "Confirm support for transactions" 424 cursor = self.connection.cursor() 425 cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') 426 self.connection._commit() 427 cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') 428 self.connection._rollback() 429 cursor.execute('SELECT COUNT(X) FROM ROLLBACK_TEST') 430 count, = cursor.fetchone() 431 cursor.execute('DROP TABLE ROLLBACK_TEST') 432 self.connection._commit() 433 return count == 0 434 435 def _supports_stddev(self): 419 if self._supports_transactions is None: 420 cursor = self.connection.cursor() 421 cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') 422 self.connection._commit() 423 cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') 424 self.connection._rollback() 425 cursor.execute('SELECT COUNT(X) FROM ROLLBACK_TEST') 426 count, = cursor.fetchone() 427 cursor.execute('DROP TABLE ROLLBACK_TEST') 428 self.connection._commit() 429 self._supports_transactions = (count == 0) 430 return self._supports_transactions 431 432 @property 433 def supports_stddev(self): 436 434 "Confirm support for STDDEV and related stats functions" 437 class StdDevPop(object): 438 sql_function = 'STDDEV_POP' 439 440 try: 441 self.connection.ops.check_aggregate_support(StdDevPop()) 442 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 449 return True 435 if self._supports_stddev is None: 436 class StdDevPop(object): 437 sql_function = 'STDDEV_POP' 438 439 try: 440 self.connection.ops.check_aggregate_support(StdDevPop()) 441 self._supports_stddev = True 442 except NotImplementedError: 443 self._supports_stddev = False 444 return self._supports_stddev 450 445 451 446 452 447 class BaseDatabaseOperations(object): -
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..ed5f68a 100644
a b class DatabaseFeatures(BaseDatabaseFeatures): 153 153 def __init__(self, connection): 154 154 super(DatabaseFeatures, self).__init__(connection) 155 155 self._storage_engine = None 156 self._can_introspect_foreign_keys = None 156 157 157 158 def _mysql_storage_engine(self): 158 159 "Internal method used in Django tests. Don't rely on this from your code" … … class DatabaseFeatures(BaseDatabaseFeatures): 169 170 self._storage_engine = result[1] 170 171 return self._storage_engine 171 172 172 def _can_introspect_foreign_keys(self): 173 @property 174 def can_introspect_foreign_keys(self): 173 175 "Confirm support for introspected foreign keys" 174 return self._mysql_storage_engine() != 'MyISAM' 176 if self._can_introspect_foreign_keys is None: 177 self._can_introspect_foreign_keys = ( 178 self._mysql_storage_engine() != 'MyISAM') 179 return self._can_introspect_foreign_keys 175 180 176 181 class DatabaseOperations(BaseDatabaseOperations): 177 182 compiler_module = "django.db.backends.mysql.compiler"