mirror of
https://github.com/django/django.git
synced 2025-07-19 11:15:19 +00:00
Fixed #14180 -- Prevented unneeded index creation on MySQL-InnoDB
Thanks zimnyx for the report and Simon Charette, Tim Graham for the reviews.
This commit is contained in:
parent
4718296546
commit
2ceb10f3b0
5 changed files with 42 additions and 9 deletions
|
@ -72,14 +72,14 @@ class SQLCommandsTestCase(TestCase):
|
|||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", category=RemovedInDjango20Warning)
|
||||
output = sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
# PostgreSQL creates one additional index for CharField
|
||||
self.assertIn(self.count_ddl(output, 'CREATE INDEX'), [3, 4])
|
||||
# Number of indexes is backend-dependent
|
||||
self.assertTrue(1 <= self.count_ddl(output, 'CREATE INDEX') <= 4)
|
||||
|
||||
def test_sql_destroy_indexes(self):
|
||||
app_config = apps.get_app_config('commands_sql')
|
||||
output = sql_destroy_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
# PostgreSQL creates one additional index for CharField
|
||||
self.assertIn(self.count_ddl(output, 'DROP INDEX'), [3, 4])
|
||||
# Number of indexes is backend-dependent
|
||||
self.assertTrue(1 <= self.count_ddl(output, 'DROP INDEX') <= 4)
|
||||
|
||||
def test_sql_all(self):
|
||||
app_config = apps.get_app_config('commands_sql')
|
||||
|
@ -88,8 +88,8 @@ class SQLCommandsTestCase(TestCase):
|
|||
output = sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
|
||||
|
||||
self.assertEqual(self.count_ddl(output, 'CREATE TABLE'), 3)
|
||||
# PostgreSQL creates one additional index for CharField
|
||||
self.assertIn(self.count_ddl(output, 'CREATE INDEX'), [3, 4])
|
||||
# Number of indexes is backend-dependent
|
||||
self.assertTrue(1 <= self.count_ddl(output, 'CREATE INDEX') <= 4)
|
||||
|
||||
|
||||
class TestRouter(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue