diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 463150f8a1..08ea0a51d3 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -670,6 +670,18 @@ class BasicExpressionsTests(TestCase): # contain nested aggregates. self.assertNotIn('GROUP BY', sql) + @skipUnlessDBFeature('supports_over_clause') + def test_aggregate_rawsql_annotation(self): + with self.assertNumQueries(1) as ctx: + aggregate = Company.objects.annotate( + salary=RawSQL('SUM(num_chairs) OVER (ORDER BY num_employees)', []), + ).aggregate( + count=Count('pk'), + ) + self.assertEqual(aggregate, {'count': 3}) + sql = ctx.captured_queries[0]['sql'] + self.assertNotIn('GROUP BY', sql) + def test_explicit_output_field(self): class FuncA(Func): output_field = CharField()