1
0
mirror of https://github.com/django/django.git synced 2025-01-18 14:24:39 +00:00

Refs #21286 -- Fixed serializer test with primary key TextField.

This commit is contained in:
Adam Zapletal 2024-11-12 08:15:17 -06:00 committed by Sarah Boyce
parent 0977ec671a
commit 1636912bf1
2 changed files with 19 additions and 6 deletions

View File

@ -242,8 +242,11 @@ class SmallPKData(models.Model):
data = models.SmallIntegerField(primary_key=True) data = models.SmallIntegerField(primary_key=True)
# class TextPKData(models.Model): class TextPKData(models.Model):
# data = models.TextField(primary_key=True) data = models.TextField(primary_key=True)
class Meta:
required_db_features = ["supports_index_on_text_field"]
class TimePKData(models.Model): class TimePKData(models.Model):

View File

@ -68,6 +68,7 @@ from .models import (
SmallPKData, SmallPKData,
Tag, Tag,
TextData, TextData,
TextPKData,
TimeData, TimeData,
TimePKData, TimePKData,
UniqueAnchor, UniqueAnchor,
@ -387,10 +388,15 @@ The end.""",
(pk_obj, 750, SmallPKData, 12), (pk_obj, 750, SmallPKData, 12),
(pk_obj, 751, SmallPKData, -12), (pk_obj, 751, SmallPKData, -12),
(pk_obj, 752, SmallPKData, 0), (pk_obj, 752, SmallPKData, 0),
# (pk_obj, 760, TextPKData, """This is a long piece of text. (
# It contains line breaks. pk_obj,
# Several of them. 760,
# The end."""), 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, 770, TimePKData, datetime.time(10, 42, 37)),
(pk_obj, 791, UUIDData, uuid_obj), (pk_obj, 791, UUIDData, uuid_obj),
(fk_obj, 792, FKToUUID, 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): class SerializerDataTests(TestCase):
pass pass