|
@@ -158,36 +158,36 @@ class IndexesTests(SimpleTestCase):
|
|
|
|
|
|
@skipUnlessDBFeature('supports_tablespaces')
|
|
|
def test_db_tablespace(self):
|
|
|
- with connection.schema_editor() as editor:
|
|
|
-
|
|
|
- for fields in [
|
|
|
-
|
|
|
- ['shortcut'],
|
|
|
-
|
|
|
- ['author'],
|
|
|
-
|
|
|
- ['shortcut', 'isbn'],
|
|
|
-
|
|
|
- ['title', 'author'],
|
|
|
- ]:
|
|
|
- with self.subTest(fields=fields):
|
|
|
- index = models.Index(fields=fields, db_tablespace='idx_tbls2')
|
|
|
- self.assertIn('"idx_tbls2"', str(index.create_sql(Book, editor)).lower())
|
|
|
-
|
|
|
- for fields in [['author'], ['shortcut', 'isbn'], ['title', 'author']]:
|
|
|
- with self.subTest(fields=fields):
|
|
|
- index = models.Index(fields=fields)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if settings.DEFAULT_INDEX_TABLESPACE:
|
|
|
- self.assertIn(
|
|
|
- '"%s"' % settings.DEFAULT_INDEX_TABLESPACE,
|
|
|
- str(index.create_sql(Book, editor)).lower()
|
|
|
- )
|
|
|
- else:
|
|
|
- self.assertNotIn('TABLESPACE', str(index.create_sql(Book, editor)))
|
|
|
-
|
|
|
-
|
|
|
- index = models.Index(fields=['shortcut'])
|
|
|
- self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())
|
|
|
+ editor = connection.schema_editor()
|
|
|
+
|
|
|
+ for fields in [
|
|
|
+
|
|
|
+ ['shortcut'],
|
|
|
+
|
|
|
+ ['author'],
|
|
|
+
|
|
|
+ ['shortcut', 'isbn'],
|
|
|
+
|
|
|
+ ['title', 'author'],
|
|
|
+ ]:
|
|
|
+ with self.subTest(fields=fields):
|
|
|
+ index = models.Index(fields=fields, db_tablespace='idx_tbls2')
|
|
|
+ self.assertIn('"idx_tbls2"', str(index.create_sql(Book, editor)).lower())
|
|
|
+
|
|
|
+ for fields in [['author'], ['shortcut', 'isbn'], ['title', 'author']]:
|
|
|
+ with self.subTest(fields=fields):
|
|
|
+ index = models.Index(fields=fields)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if settings.DEFAULT_INDEX_TABLESPACE:
|
|
|
+ self.assertIn(
|
|
|
+ '"%s"' % settings.DEFAULT_INDEX_TABLESPACE,
|
|
|
+ str(index.create_sql(Book, editor)).lower()
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ self.assertNotIn('TABLESPACE', str(index.create_sql(Book, editor)))
|
|
|
+
|
|
|
+
|
|
|
+ index = models.Index(fields=['shortcut'])
|
|
|
+ self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())
|