Fixed #26808 -- Added Meta.indexes for class-based indexes.

* Added the index name to its deconstruction.
* Added indexes to sqlite3.schema._remake_table() so that indexes
  aren't dropped when _remake_table() is called.

Thanks timgraham & MarkusH for review and advice.
This commit is contained in:
Akshesh 2016-06-20 21:20:05 +05:30 committed by Tim Graham
parent d117567c7d
commit 6a8372e6ec
14 changed files with 246 additions and 35 deletions

View file

@ -16,6 +16,9 @@ class IndexesTests(TestCase):
index = models.Index(fields=['title'])
same_index = models.Index(fields=['title'])
another_index = models.Index(fields=['title', 'author'])
index.model = Book
same_index.model = Book
another_index.model = Book
self.assertEqual(index, same_index)
self.assertNotEqual(index, another_index)
@ -56,7 +59,8 @@ class IndexesTests(TestCase):
def test_deconstruction(self):
index = models.Index(fields=['title'])
index.set_name_with_model(Book)
path, args, kwargs = index.deconstruct()
self.assertEqual(path, 'django.db.models.Index')
self.assertEqual(args, ())
self.assertEqual(kwargs, {'fields': ['title']})
self.assertEqual(kwargs, {'fields': ['title'], 'name': 'model_index_title_196f42_idx'})