mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Refs #21286 -- Fixed and enabled TextField primary key serializer test data.
The `TextPKData` serializer test data was failing on some database backends. This is because a primary key requires an index, and not all backends support indexes on `TextField`. This patch ensures that the `TextPKData` model and related test are only included with database backends that have the `supports_index_on_text_field` feature.
This commit is contained in:
parent
b9aa3239ab
commit
babfc65f81
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user