mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #29172 -- Fixed crash with Window expression in a subquery.
This commit is contained in:
committed by
Tim Graham
parent
ba4a986240
commit
fa352626c2
@@ -650,6 +650,19 @@ class WindowFunctionTests(TestCase):
|
||||
salary=Window(expression=Sum(Value(10000), order_by=F('pk').asc())),
|
||||
)
|
||||
|
||||
def test_window_expression_within_subquery(self):
|
||||
subquery_qs = Employee.objects.annotate(
|
||||
highest=Window(FirstValue('id'), partition_by=F('department'), order_by=F('salary').desc())
|
||||
).values('highest')
|
||||
highest_salary = Employee.objects.filter(pk__in=subquery_qs)
|
||||
self.assertSequenceEqual(highest_salary.values('department', 'salary'), [
|
||||
{'department': 'Accounting', 'salary': 50000},
|
||||
{'department': 'Sales', 'salary': 55000},
|
||||
{'department': 'Marketing', 'salary': 40000},
|
||||
{'department': 'IT', 'salary': 60000},
|
||||
{'department': 'Management', 'salary': 100000}
|
||||
])
|
||||
|
||||
def test_invalid_start_value_range(self):
|
||||
msg = "start argument must be a negative integer, zero, or None, but got '3'."
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
|
||||
Reference in New Issue
Block a user