diff --git a/tests/serializers/models/data.py b/tests/serializers/models/data.py index bb76bfba48..b82e8b4b33 100644 --- a/tests/serializers/models/data.py +++ b/tests/serializers/models/data.py @@ -242,8 +242,11 @@ class SmallPKData(models.Model): data = models.SmallIntegerField(primary_key=True) -# class TextPKData(models.Model): -# data = models.TextField(primary_key=True) +class TextPKData(models.Model): + data = models.TextField(primary_key=True) + + class Meta: + required_db_features = ["supports_index_on_text_field"] class TimePKData(models.Model): diff --git a/tests/serializers/test_data.py b/tests/serializers/test_data.py index 1f8f38ba0f..808db41634 100644 --- a/tests/serializers/test_data.py +++ b/tests/serializers/test_data.py @@ -68,6 +68,7 @@ from .models import ( SmallPKData, Tag, TextData, + TextPKData, TimeData, TimePKData, UniqueAnchor, @@ -387,10 +388,15 @@ The end.""", (pk_obj, 750, SmallPKData, 12), (pk_obj, 751, SmallPKData, -12), (pk_obj, 752, SmallPKData, 0), - # (pk_obj, 760, TextPKData, """This is a long piece of text. - # It contains line breaks. - # Several of them. - # The end."""), + ( + pk_obj, + 760, + TextPKData, + """This is a long piece of text. + It contains line breaks. + Several of them. + The end.""", + ), (pk_obj, 770, TimePKData, datetime.time(10, 42, 37)), (pk_obj, 791, UUIDData, uuid_obj), (fk_obj, 792, FKToUUID, uuid_obj), @@ -429,6 +435,10 @@ if connection.features.interprets_empty_strings_as_nulls: ] +if not connection.features.supports_index_on_text_field: + test_data = [data for data in test_data if data[2] != TextPKData] + + class SerializerDataTests(TestCase): pass