1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[3.0.x] Fixed #30800 -- Fixed migrations crash when altering a field with custom db_type().

Regression in 1378d665a1.
Backport of 580e644f24 from master
This commit is contained in:
Mariusz Felisiak
2019-09-25 12:32:24 +02:00
parent f4b7acedbf
commit 1adf85d168
2 changed files with 24 additions and 1 deletions

View File

@@ -857,6 +857,26 @@ class SchemaTests(TransactionTestCase):
with self.assertRaisesMessage(DataError, msg):
editor.alter_field(Author, old_field, new_field, strict=True)
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific')
def test_alter_field_with_custom_db_type(self):
from django.contrib.postgres.fields import ArrayField
class Foo(Model):
field = ArrayField(CharField(max_length=255))
class Meta:
app_label = 'schema'
with connection.schema_editor() as editor:
editor.create_model(Foo)
self.isolated_local_models = [Foo]
old_field = Foo._meta.get_field('field')
new_field = ArrayField(CharField(max_length=16))
new_field.set_attributes_from_name('field')
new_field.model = Foo
with connection.schema_editor() as editor:
editor.alter_field(Foo, old_field, new_field, strict=True)
def test_alter_textfield_to_null(self):
"""
#24307 - Should skip an alter statement on databases with