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

Fixed #28465 -- Unified index SQL creation in DatabaseSchemaEditor

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2017-08-03 23:33:06 +02:00
parent d18227e341
commit 831358f23d
6 changed files with 40 additions and 44 deletions

View File

@@ -113,7 +113,7 @@ class IndexesTests(SimpleTestCase):
]:
with self.subTest(fields=fields):
index = models.Index(fields=fields, db_tablespace='idx_tbls2')
self.assertIn('"idx_tbls2"', index.create_sql(Book, editor).lower())
self.assertIn('"idx_tbls2"', str(index.create_sql(Book, editor)).lower())
# Indexes without db_tablespace attribute.
for fields in [['author'], ['shortcut', 'isbn'], ['title', 'author']]:
with self.subTest(fields=fields):
@@ -124,11 +124,11 @@ class IndexesTests(SimpleTestCase):
if settings.DEFAULT_INDEX_TABLESPACE:
self.assertIn(
'"%s"' % settings.DEFAULT_INDEX_TABLESPACE,
index.create_sql(Book, editor).lower()
str(index.create_sql(Book, editor)).lower()
)
else:
self.assertNotIn('TABLESPACE', index.create_sql(Book, editor))
self.assertNotIn('TABLESPACE', str(index.create_sql(Book, editor)))
# Field with db_tablespace specified on the model and an index
# without db_tablespace.
index = models.Index(fields=['shortcut'])
self.assertIn('"idx_tbls"', index.create_sql(Book, editor).lower())
self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())