From 2e55790838a75bf25a11115536dae57880cfccfb Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sat, 14 Jan 2017 06:31:34 -0500 Subject: [PATCH] Refs #25226 -- Cloned ArrayField.base_field on deconstruction. This prevents the base_field from sharing attributes with the one used during migrations. --- django/contrib/postgres/fields/array.py | 2 +- tests/postgres_tests/test_array.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index e570a3273d..b70ae37a3a 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -92,7 +92,7 @@ class ArrayField(Field): if path == 'django.contrib.postgres.fields.array.ArrayField': path = 'django.contrib.postgres.fields.ArrayField' kwargs.update({ - 'base_field': self.base_field, + 'base_field': self.base_field.clone(), 'size': self.size, }) return name, path, args, kwargs diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 886a983180..69ae5f3cda 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -441,6 +441,7 @@ class TestMigrations(TransactionTestCase): name, path, args, kwargs = field.deconstruct() new = ArrayField(*args, **kwargs) self.assertEqual(type(new.base_field), type(field.base_field)) + self.assertIsNot(new.base_field, field.base_field) def test_deconstruct_with_size(self): field = ArrayField(models.IntegerField(), size=3)