blob: 7f86f6a2056aa0046a1bc0aed9739bb57490acda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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')
|