Merge pull request #3765 from wlanslovenija/ticket_24034
Fixed #24034 -- Don't always overwrite deconstruct path.
This commit is contained in:
commit
936e87c97b
|
@ -82,7 +82,8 @@ class ArrayField(Field):
|
|||
|
||||
def deconstruct(self):
|
||||
name, path, args, kwargs = super(ArrayField, self).deconstruct()
|
||||
path = 'django.contrib.postgres.fields.ArrayField'
|
||||
if path == 'django.contrib.postgres.fields.array.ArrayField':
|
||||
path = 'django.contrib.postgres.fields.ArrayField'
|
||||
kwargs.update({
|
||||
'base_field': self.base_field,
|
||||
'size': self.size,
|
||||
|
|
|
@ -32,3 +32,8 @@ class CharFieldModel(models.Model):
|
|||
|
||||
class TextFieldModel(models.Model):
|
||||
field = models.TextField()
|
||||
|
||||
|
||||
class ArrayFieldSubclass(ArrayField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ArrayFieldSubclass, self).__init__(models.IntegerField())
|
||||
|
|
|
@ -10,7 +10,7 @@ from django import forms
|
|||
from django.test import TestCase, override_settings
|
||||
from django.utils import timezone
|
||||
|
||||
from .models import IntegerArrayModel, NullableIntegerArrayModel, CharArrayModel, DateTimeArrayModel, NestedIntegerArrayModel
|
||||
from .models import IntegerArrayModel, NullableIntegerArrayModel, CharArrayModel, DateTimeArrayModel, NestedIntegerArrayModel, ArrayFieldSubclass
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL required')
|
||||
|
@ -228,6 +228,15 @@ class TestMigrations(TestCase):
|
|||
new = ArrayField(*args, **kwargs)
|
||||
self.assertEqual(new.base_field.max_length, field.base_field.max_length)
|
||||
|
||||
def test_subclass_deconstruct(self):
|
||||
field = ArrayField(models.IntegerField())
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
self.assertEqual(path, 'django.contrib.postgres.fields.ArrayField')
|
||||
|
||||
field = ArrayFieldSubclass()
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
self.assertEqual(path, 'postgres_tests.models.ArrayFieldSubclass')
|
||||
|
||||
@override_settings(MIGRATION_MODULES={
|
||||
"postgres_tests": "postgres_tests.array_default_migrations",
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue