mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #36431 -- Returned tuples for multi-column ForeignObject in values()/values_list().
Thanks Jacob Walls and Simon Charette for tests. Signed-off-by: SaJH <wogur981208@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from uuid import UUID
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import Post, Tenant, User
|
||||
from .models import Comment, Post, Tenant, User
|
||||
|
||||
|
||||
class CompositePKValuesTests(TestCase):
|
||||
@@ -210,3 +210,17 @@ class CompositePKValuesTests(TestCase):
|
||||
{"pk": self.user_3.pk, "id": self.user_3.id},
|
||||
),
|
||||
)
|
||||
|
||||
def test_foreign_object_values(self):
|
||||
Comment.objects.create(id=1, user=self.user_1, integer=42)
|
||||
testcases = {
|
||||
"all": Comment.objects.all(),
|
||||
"exclude_user_email": Comment.objects.exclude(user__email__endswith="net"),
|
||||
}
|
||||
for name, queryset in testcases.items():
|
||||
with self.subTest(name=name):
|
||||
values = list(queryset.values("user", "integer"))
|
||||
self.assertEqual(
|
||||
values[0]["user"], (self.user_1.tenant_id, self.user_1.id)
|
||||
)
|
||||
self.assertEqual(values[0]["integer"], 42)
|
||||
|
||||
Reference in New Issue
Block a user