[1.9.x] Refs #26034 -- Corrected a schema test to work with the correct field state.
Backport of d47f6d75ef67dbd18abf2bb927753f739a9c117d from master
This commit is contained in:
parent
f40c91cdef
commit
54c0dea22e
@ -1778,15 +1778,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")
|
||||
@ -1809,11 +1808,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…
x
Reference in New Issue
Block a user