mirror of
https://github.com/django/django.git
synced 2025-08-30 23:37:50 +00:00
Fixed #26458 -- Based Avg's default output_field resolution on its source field type.
Thanks Tim for the review and Josh for the input.
This commit is contained in:
parent
361cb7a857
commit
a6074e8908
2 changed files with 12 additions and 4 deletions
|
@ -496,10 +496,16 @@ class AggregateTestCase(TestCase):
|
|||
self.assertEqual(vals, {"num_authors__avg": Approximate(1.66, places=1)})
|
||||
|
||||
def test_avg_duration_field(self):
|
||||
# Explicit `output_field`.
|
||||
self.assertEqual(
|
||||
Publisher.objects.aggregate(Avg('duration', output_field=DurationField())),
|
||||
{'duration__avg': datetime.timedelta(days=1, hours=12)}
|
||||
)
|
||||
# Implicit `output_field`.
|
||||
self.assertEqual(
|
||||
Publisher.objects.aggregate(Avg('duration')),
|
||||
{'duration__avg': datetime.timedelta(days=1, hours=12)}
|
||||
)
|
||||
|
||||
def test_sum_duration_field(self):
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue