mirror of https://github.com/django/django.git
[1.10.x] Refs #26034 -- Corrected a schema test to work with the correct field state.
Backport of d47f6d75ef
from master
This commit is contained in:
parent
b2c28a3770
commit
5c04852455
|
@ -1799,15 +1799,14 @@ class SchemaTests(TransactionTestCase):
|
|||
self.get_constraints_for_column(BookWithoutAuthor, 'title'),
|
||||
['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq']
|
||||
)
|
||||
# Alter to remove unique=True (should drop unique index) # XXX: bug!
|
||||
old_field = BookWithoutAuthor._meta.get_field('title')
|
||||
new_field = CharField(max_length=100, db_index=True)
|
||||
new_field.set_attributes_from_name('title')
|
||||
# Alter to remove unique=True (should drop unique index)
|
||||
new_field2 = CharField(max_length=100, db_index=True)
|
||||
new_field2.set_attributes_from_name('title')
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(BookWithoutAuthor, old_field, new_field, strict=True)
|
||||
editor.alter_field(BookWithoutAuthor, new_field, new_field2, strict=True)
|
||||
self.assertEqual(
|
||||
self.get_constraints_for_column(BookWithoutAuthor, 'title'),
|
||||
['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq']
|
||||
['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like']
|
||||
)
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific")
|
||||
|
@ -1830,11 +1829,10 @@ class SchemaTests(TransactionTestCase):
|
|||
['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key']
|
||||
)
|
||||
# Alter to remove db_index=True
|
||||
old_field = Tag._meta.get_field('slug')
|
||||
new_field = SlugField(unique=True)
|
||||
new_field.set_attributes_from_name('slug')
|
||||
new_field2 = SlugField(unique=True)
|
||||
new_field2.set_attributes_from_name('slug')
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Tag, old_field, new_field, strict=True)
|
||||
editor.alter_field(Tag, new_field, new_field2, strict=True)
|
||||
self.assertEqual(
|
||||
self.get_constraints_for_column(Tag, 'slug'),
|
||||
['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key']
|
||||
|
|
Loading…
Reference in New Issue