mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #34368 -- Made subquery raise NotSupportedError when referencing outer window expression.
Regression in f387d024fc
.
Co-authored-by: Jannis Vajen <jvajen@gmail.com>
This commit is contained in:
parent
b15f162f25
commit
c67ea79aa9
3 changed files with 25 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue