-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Fixed #36431 -- Returned tuples for multi-column ForeignObject
in values()
/values_list()
.
#19771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ForeignObject
in values()
/values_list()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch @JaeHyuckSa
ea5d607
to
010dd4e
Compare
010dd4e
to
2a50a5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @JaeHyuckSa
I made this a release blocker for 5.2, could you rebase main and add a release note to 5.2.6. Something like
* Fixed a bug where using ``QuerySet.values()`` or ``values_list()`` with a
``ForeignObject`` composed of multiple fields returned incorrect results
instead of tuples of the referenced fields (:ticket:`36431`).
In good news, this PR passes this test case if I comment out the ValueError raising the message "The QuerySet value for the 'in' lookup must have 2 selected fields..." given that diff --git a/tests/composite_pk/test_filter.py b/tests/composite_pk/test_filter.py
index d7ecfbec11..c4b393d6ea 100644
--- a/tests/composite_pk/test_filter.py
+++ b/tests/composite_pk/test_filter.py
@@ -460,6 +460,11 @@ class CompositePKFilterTests(TestCase):
queryset = User.objects.filter(comments__in=subquery)
self.assertSequenceEqual(queryset, (self.user_2,))
+ def test_filter_comments_by_users_subquery(self):
+ subquery = Comment.objects.filter(id=3).values("user")
+ queryset = Comment.objects.filter(user__in=subquery)
+ self.assertSequenceEqual(queryset, (self.comment_3,))
+
def test_cannot_cast_pk(self):
msg = "Cast expression does not support composite primary keys."
with self.assertRaisesMessage(ValueError, msg): Opened ticket-36584 for this. |
2a50a5d
to
076cf81
Compare
@jacobtylerwalls Interesting — I’ll pick this up as a follow-up to the current PR. Thank you very much for flagging it. |
…ues()/values_list(). Thanks Jacob Walls and Simon Charette for tests. Signed-off-by: SaJH <wogur981208@gmail.com>
076cf81
to
26ec033
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Trac ticket number
ticket-36431
Branch description
Thanks to @jacobtylerwalls and @charettes for the tests.
Checklist
main
branch.