1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Merge pull request #3765 from wlanslovenija/ticket_24034

Fixed #24034 -- Don't always overwrite deconstruct path.
This commit is contained in:
Marc Tamlyn 2014-12-22 00:41:13 +00:00
commit 936e87c97b
3 changed files with 17 additions and 2 deletions

View File

@ -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,

View File

@ -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())

View File

@ -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",
})