mirror of https://github.com/django/django.git
Refs #26602 -- Added tests for aggregating over a RawSQL() annotation.
Fixed in 3f32154f40
.
Thanks Manav Agarwal for initial test.
This commit is contained in:
parent
1adc09064f
commit
b989d21336
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue