summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2014-07-15 12:30:34 +0100
committerMarc Tamlyn <marc.tamlyn@gmail.com>2014-07-29 10:37:11 +0100
commitef9f109013adc6e140c1a71d874aa88e893657b7 (patch)
treee90689eb21ddd1df2cbe81e41544a9b0c2de8eca /tests/postgres_tests/test_array.py
parente5619330e2d3bf901155e98ef3fa7d224b6a260a (diff)
Fixed #22962 -- Default values for ArrayField with migrations.
Fields normally try to force the default value to a string. As translatable strings are not valid default values for ArrayField, we can remove this behaviour which was causing issues with some migrations. Thanks to @schinckel for the report.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 1fc54defe7..33cf837dd4 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -4,10 +4,11 @@ import unittest
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
from django.core import exceptions, serializers
+from django.core.management import call_command
from django.db import models, IntegrityError, connection
from django.db.migrations.writer import MigrationWriter
from django import forms
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.utils import timezone
from .models import IntegerArrayModel, NullableIntegerArrayModel, CharArrayModel, DateTimeArrayModel, NestedIntegerArrayModel
@@ -226,6 +227,13 @@ class TestMigrations(TestCase):
statement, imports = MigrationWriter.serialize(field)
self.assertEqual(statement, 'django.contrib.postgres.fields.ArrayField(models.CharField(max_length=20), size=None)')
+ @override_settings(MIGRATION_MODULES={
+ "postgres_tests": "postgres_tests.array_default_migrations",
+ })
+ def test_adding_field_with_default(self):
+ # See #22962
+ call_command('migrate', 'postgres_tests', verbosity=0)
+
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL required')
class TestSerialization(TestCase):