Refs #28643 -- Changed Avg() to use NumericOutputFieldMixin.

Keeps precision instead of forcing DecimalField to FloatField.
This commit is contained in:
Nick Pope 2018-12-01 23:46:28 +00:00 committed by Tim Graham
parent 3d5e0f8394
commit c690afb873
6 changed files with 23 additions and 21 deletions

View file

@ -401,7 +401,7 @@ class AggregationTests(TestCase):
When(pages__lt=400, then='discount_price'),
output_field=DecimalField()
)))['test'],
22.27, places=2
Decimal('22.27'), places=2
)
def test_distinct_conditional_aggregate(self):
@ -1041,7 +1041,7 @@ class AggregationTests(TestCase):
books = Book.objects.values_list("publisher__name").annotate(
Count("id"), Avg("price"), Avg("authors__age"), avg_pgs=Avg("pages")
).order_by("-publisher__name")
self.assertEqual(books[0], ('Sams', 1, 23.09, 45.0, 528.0))
self.assertEqual(books[0], ('Sams', 1, Decimal('23.09'), 45.0, 528.0))
def test_annotation_disjunction(self):
qs = Book.objects.annotate(n_authors=Count("authors")).filter(