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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user