1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[1.11.x] Fixed #28597 -- Fixed crash with the name of a model's autogenerated primary key in an Index's fields.

Backport of fb02ebe889 from master
This commit is contained in:
Mariusz Felisiak
2017-09-17 08:26:18 +02:00
committed by Tim Graham
parent a86d95726b
commit cee07ba088
4 changed files with 16 additions and 8 deletions

View File

@@ -5,9 +5,13 @@ class Book(models.Model):
title = models.CharField(max_length=50)
author = models.CharField(max_length=50)
pages = models.IntegerField(db_column='page_count')
isbn = models.CharField(max_length=50, db_tablespace='idx_tbls')
class Meta:
indexes = [models.indexes.Index(fields=['title'])]
indexes = [
models.indexes.Index(fields=['title']),
models.indexes.Index(fields=['isbn', 'id']),
]
class AbstractModel(models.Model):

View File

@@ -85,7 +85,7 @@ class IndexesTests(SimpleTestCase):
def test_name_set(self):
index_names = [index.name for index in Book._meta.indexes]
self.assertEqual(index_names, ['model_index_title_196f42_idx'])
self.assertCountEqual(index_names, ['model_index_title_196f42_idx', 'model_index_isbn_34f975_idx'])
def test_abstract_children(self):
index_names = [index.name for index in ChildModel1._meta.indexes]