mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[5.2.x] Fixed #36299 -- Prevented field selection on QuerySet.alias() after values().
Regression in65ad4ade74. Refs #28900. Thanks Jeff Iadarola for the report and tests. Co-Authored-By: OutOfFocus4 <jeff.iadarola@gmail.com> Backport of12b771a1ecfrom main
This commit is contained in:
committed by
Mariusz Felisiak
parent
d9bf0d07cc
commit
cd1aa54f5a
@@ -1470,6 +1470,10 @@ class AliasTests(TestCase):
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
getattr(qs, operation)("rating_alias")
|
||||
|
||||
def test_alias_after_values(self):
|
||||
qs = Book.objects.values_list("pk").alias(other_pk=F("pk"))
|
||||
self.assertEqual(qs.get(pk=self.b1.pk), (self.b1.pk,))
|
||||
|
||||
def test_alias_sql_injection(self):
|
||||
crafted_alias = """injected_name" from "annotations_book"; --"""
|
||||
msg = (
|
||||
|
||||
Reference in New Issue
Block a user