1
0
mirror of https://github.com/django/django.git synced 2025-10-30 09:06:13 +00:00

[1.7.x] Fixed #24015 -- Factorized create_index_sql expression

Backport of 6072f17d0 from master, with one test reinforced.
Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2014-06-20 14:32:11 +02:00
parent 2f13a48f33
commit f46a16614d
3 changed files with 20 additions and 26 deletions

View File

@@ -46,8 +46,16 @@ class SchemaIndexesTests(TestCase):
Test index handling by the db.backends.schema infrastructure.
"""
def test_index_together(self):
index_sql = connection.schema_editor()._model_indexes_sql(Article)
editor = connection.schema_editor()
index_sql = editor._model_indexes_sql(Article)
self.assertEqual(len(index_sql), 1)
# Ensure the index name is properly quoted
self.assertIn(
connection.ops.quote_name(
editor._create_index_name(Article, ['headline', 'pub_date'], suffix='_idx')
),
index_sql[0]
)
def test_index_together_single_list(self):
# Test for using index_together with a single list (#22172)