mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #26610 -- Added CITextField to contrib.postgres.
This commit is contained in:
30
tests/postgres_tests/test_citext.py
Normal file
30
tests/postgres_tests/test_citext.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
The citext PostgreSQL extension supports indexing of case-insensitive text
|
||||
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 . import PostgreSQLTestCase
|
||||
from .models import CITextTestModel
|
||||
|
||||
|
||||
class CITextTestCase(PostgreSQLTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
CITextTestModel.objects.create(name='JoHn')
|
||||
|
||||
def test_equal_lowercase(self):
|
||||
"""
|
||||
citext removes the need for iexact as the index is case-insensitive.
|
||||
"""
|
||||
self.assertEqual(CITextTestModel.objects.filter(name='john').count(), 1)
|
||||
|
||||
def test_fail_case(self):
|
||||
"""
|
||||
Creating an entry for a citext-field which clashes with an existing
|
||||
value isn't allowed.
|
||||
"""
|
||||
with self.assertRaises(IntegrityError):
|
||||
CITextTestModel.objects.create(name='John')
|
||||
Reference in New Issue
Block a user