mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
[4.2.x] Fixed #34368 -- Made subquery raise NotSupportedError when referencing outer window expression.
Regression inf387d024fc. Co-authored-by: Jannis Vajen <jvajen@gmail.com> Backport ofc67ea79aa9from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
872dade29c
commit
fc15d11f2e
@@ -1587,6 +1587,25 @@ class WindowUnsupportedTests(TestCase):
|
||||
dense_rank=Window(expression=DenseRank())
|
||||
).get()
|
||||
|
||||
def test_filter_subquery(self):
|
||||
qs = Employee.objects.annotate(
|
||||
department_salary_rank=Window(
|
||||
Rank(), partition_by="department", order_by="-salary"
|
||||
)
|
||||
)
|
||||
msg = (
|
||||
"Referencing outer query window expression is not supported: "
|
||||
"department_salary_rank."
|
||||
)
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
qs.annotate(
|
||||
employee_name=Subquery(
|
||||
Employee.objects.filter(
|
||||
age=OuterRef("department_salary_rank")
|
||||
).values("name")[:1]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class NonQueryWindowTests(SimpleTestCase):
|
||||
def test_window_repr(self):
|
||||
|
||||
Reference in New Issue
Block a user