mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
[1.11.x] Fixed #28161 -- Fixed return type of ArrayField(CITextField()).
Thanks Tim for the review.
Backport of b91868507a from master.
This commit is contained in:
@@ -12,14 +12,14 @@ class PostgreSQLTestCase(TestCase):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
# No need to keep that signal overhead for non PostgreSQL-related tests.
|
||||
from django.contrib.postgres.signals import register_hstore_handler
|
||||
from django.contrib.postgres.signals import register_type_handlers
|
||||
|
||||
connection_created.disconnect(register_hstore_handler)
|
||||
connection_created.disconnect(register_type_handlers)
|
||||
super(PostgreSQLTestCase, cls).tearDownClass()
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests")
|
||||
# To locate the widget's template.
|
||||
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
|
||||
class PostgreSQLWidgetTestCase(WidgetTest):
|
||||
class PostgreSQLWidgetTestCase(WidgetTest, PostgreSQLTestCase):
|
||||
pass
|
||||
|
||||
@@ -144,6 +144,7 @@ class Migration(migrations.Migration):
|
||||
('name', CICharField(primary_key=True, max_length=255)),
|
||||
('email', CIEmailField()),
|
||||
('description', CITextField()),
|
||||
('array_field', ArrayField(CITextField(), null=True)),
|
||||
],
|
||||
options={
|
||||
'required_db_vendor': 'postgresql',
|
||||
|
||||
@@ -105,6 +105,7 @@ class CITestModel(PostgreSQLModel):
|
||||
name = CICharField(primary_key=True, max_length=255)
|
||||
email = CIEmailField()
|
||||
description = CITextField()
|
||||
array_field = ArrayField(CITextField(), null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@@ -4,11 +4,13 @@ strings and thus eliminates the need for operations such as iexact and other
|
||||
modifiers to enforce use of an index.
|
||||
"""
|
||||
from django.db import IntegrityError
|
||||
from django.test.utils import modify_settings
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
from .models import CITestModel
|
||||
|
||||
|
||||
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
|
||||
class CITextTestCase(PostgreSQLTestCase):
|
||||
|
||||
@classmethod
|
||||
@@ -17,6 +19,7 @@ class CITextTestCase(PostgreSQLTestCase):
|
||||
name='JoHn',
|
||||
email='joHn@johN.com',
|
||||
description='Average Joe named JoHn',
|
||||
array_field=['JoE', 'jOhn'],
|
||||
)
|
||||
|
||||
def test_equal_lowercase(self):
|
||||
@@ -34,3 +37,8 @@ class CITextTestCase(PostgreSQLTestCase):
|
||||
"""
|
||||
with self.assertRaises(IntegrityError):
|
||||
CITestModel.objects.create(name='John')
|
||||
|
||||
def test_array_field(self):
|
||||
instance = CITestModel.objects.get()
|
||||
self.assertEqual(instance.array_field, self.john.array_field)
|
||||
self.assertTrue(CITestModel.objects.filter(array_field__contains=['joe']).exists())
|
||||
|
||||
Reference in New Issue
Block a user