Refs #25226 -- Cloned ArrayField.base_field on deconstruction.

This prevents the base_field from sharing attributes with the one used
during migrations.
This commit is contained in:
Simon Charette 2017-01-14 06:31:34 -05:00 committed by Tim Graham
parent f4c0eec713
commit 2e55790838
2 changed files with 2 additions and 1 deletions

View File

@ -92,7 +92,7 @@ class ArrayField(Field):
if path == 'django.contrib.postgres.fields.array.ArrayField': if path == 'django.contrib.postgres.fields.array.ArrayField':
path = 'django.contrib.postgres.fields.ArrayField' path = 'django.contrib.postgres.fields.ArrayField'
kwargs.update({ kwargs.update({
'base_field': self.base_field, 'base_field': self.base_field.clone(),
'size': self.size, 'size': self.size,
}) })
return name, path, args, kwargs return name, path, args, kwargs

View File

@ -441,6 +441,7 @@ class TestMigrations(TransactionTestCase):
name, path, args, kwargs = field.deconstruct() name, path, args, kwargs = field.deconstruct()
new = ArrayField(*args, **kwargs) new = ArrayField(*args, **kwargs)
self.assertEqual(type(new.base_field), type(field.base_field)) self.assertEqual(type(new.base_field), type(field.base_field))
self.assertIsNot(new.base_field, field.base_field)
def test_deconstruct_with_size(self): def test_deconstruct_with_size(self):
field = ArrayField(models.IntegerField(), size=3) field = ArrayField(models.IntegerField(), size=3)