1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #33872 -- Deprecated django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField.

This commit is contained in:
Mariusz Felisiak
2022-08-03 11:42:51 +02:00
committed by GitHub
parent 09e837c5d9
commit cb791a2540
15 changed files with 228 additions and 21 deletions

View File

@@ -85,3 +85,65 @@ class DeprecatedFieldsTests(SimpleTestCase):
),
],
)
@skipUnless(connection.vendor == "postgresql", "PostgreSQL specific SQL")
def test_postgres_ci_fields_deprecated(self):
from django.contrib.postgres.fields import (
ArrayField,
CICharField,
CIEmailField,
CITextField,
)
class PostgresCIFieldsModel(models.Model):
ci_char = CICharField(max_length=255)
ci_email = CIEmailField()
ci_text = CITextField()
array_ci_text = ArrayField(CITextField())
self.assertEqual(
PostgresCIFieldsModel.check(),
[
checks.Warning(
"django.contrib.postgres.fields.CICharField is deprecated. Support "
"for it (except in historical migrations) will be removed in "
"Django 5.1.",
hint=(
'Use CharField(db_collation="") with a case-insensitive '
"non-deterministic collation instead."
),
obj=PostgresCIFieldsModel._meta.get_field("ci_char"),
id="fields.W905",
),
checks.Warning(
"django.contrib.postgres.fields.CIEmailField is deprecated. "
"Support for it (except in historical migrations) will be removed "
"in Django 5.1.",
hint=(
'Use EmailField(db_collation="") with a case-insensitive '
"non-deterministic collation instead."
),
obj=PostgresCIFieldsModel._meta.get_field("ci_email"),
id="fields.W906",
),
checks.Warning(
"django.contrib.postgres.fields.CITextField is deprecated. Support "
"for it (except in historical migrations) will be removed in "
"Django 5.1.",
hint=(
'Use TextField(db_collation="") with a case-insensitive '
"non-deterministic collation instead."
),
obj=PostgresCIFieldsModel._meta.get_field("ci_text"),
id="fields.W907",
),
checks.Warning(
"Base field for array has warnings:\n"
" django.contrib.postgres.fields.CITextField is deprecated. "
"Support for it (except in historical migrations) will be removed "
"in Django 5.1. (fields.W907)",
obj=PostgresCIFieldsModel._meta.get_field("array_ci_text"),
id="postgres.W004",
),
],
)