1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +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)
# 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):

View File

@ -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