#36373: select_related() doesn't work when targeting composite primary keys
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for the report, it's worth pointing out that the issue is not
specific to calling `select_related` without a subset of relationship the
following test fails as well and is a more common usage of
`select_related`
{{{#!diff
diff --git a/tests/composite_pk/tests.py b/tests/composite_pk/tests.py
index 5dea23c9f2..6983e13945 100644
--- a/tests/composite_pk/tests.py
+++ b/tests/composite_pk/tests.py
@@ -184,6 +184,11 @@ def test_only(self):
with self.assertNumQueries(1):
self.assertEqual(user.email, self.user.email)
+ def test_select_related(self):
+ with self.assertNumQueries(1):
+ for comment in Comment.objects.select_related("user"):
+ comment.user
+
def test_model_forms(self):
fields = ["tenant", "id", "user_id", "text", "integer"]
self.assertEqual(list(CommentForm.base_fields), fields)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36373#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070196ab7aa830-4461701a-acfd-4dbc-abfe-c89f3d476e11-000000%40eu-central-1.amazonses.com.