1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #25534, Fixed #31639 -- Added support for transform references in expressions.

Thanks Mariusz Felisiak and Simon Charette for reviews.
This commit is contained in:
Ian Foote
2020-11-15 22:43:47 +00:00
committed by Mariusz Felisiak
parent e46ca51c24
commit 8b040e3cbb
14 changed files with 354 additions and 82 deletions

View File

@@ -151,6 +151,14 @@ class AggregateTestCase(TestCase):
vals = Store.objects.filter(name="Amazon.com").aggregate(amazon_mean=Avg("books__rating"))
self.assertEqual(vals, {'amazon_mean': Approximate(4.08, places=2)})
def test_aggregate_transform(self):
vals = Store.objects.aggregate(min_month=Min('original_opening__month'))
self.assertEqual(vals, {'min_month': 3})
def test_aggregate_join_transform(self):
vals = Publisher.objects.aggregate(min_year=Min('book__pubdate__year'))
self.assertEqual(vals, {'min_year': 1991})
def test_annotate_basic(self):
self.assertQuerysetEqual(
Book.objects.annotate().order_by('pk'), [