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

Fixed #27859 -- Ignored db_index for TextField/BinaryField on Oracle and MySQL.

Thanks Zubair Alam for the initial patch and Tim Graham for the review.
This commit is contained in:
Mariusz Felisiak
2017-05-23 17:02:40 +02:00
committed by GitHub
parent b3eb6eaf1a
commit 538bf43458
13 changed files with 114 additions and 19 deletions

View File

@@ -29,11 +29,11 @@ from .fields import (
CustomManyToManyField, InheritedManyToManyField, MediumBlobField,
)
from .models import (
Author, AuthorWithDefaultHeight, AuthorWithEvenLongerName,
AuthorWithIndexedName, Book, BookForeignObj, BookWeak, BookWithLongName,
BookWithO2O, BookWithoutAuthor, BookWithSlug, IntegerPK, Node, Note,
NoteRename, Tag, TagIndexed, TagM2MTest, TagUniqueRename, Thing,
UniqueTest, new_apps,
Author, AuthorTextFieldWithIndex, AuthorWithDefaultHeight,
AuthorWithEvenLongerName, AuthorWithIndexedName, Book, BookForeignObj,
BookWeak, BookWithLongName, BookWithO2O, BookWithoutAuthor, BookWithSlug,
IntegerPK, Node, Note, NoteRename, Tag, TagIndexed, TagM2MTest,
TagUniqueRename, Thing, UniqueTest, new_apps,
)
@@ -1749,6 +1749,13 @@ class SchemaTests(TransactionTestCase):
self.get_indexes(Book._meta.db_table),
)
def test_text_field_with_db_index(self):
with connection.schema_editor() as editor:
editor.create_model(AuthorTextFieldWithIndex)
# The text_field index is present if the database supports it.
assertion = self.assertIn if connection.features.supports_index_on_text_field else self.assertNotIn
assertion('text_field', self.get_indexes(AuthorTextFieldWithIndex._meta.db_table))
def test_primary_key(self):
"""
Tests altering of the primary key