1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Added DatabaseFeatures.rounds_to_even.

This feature flag useful with MongoDB: "Rounding to the nearest even
value supports more even distribution of rounded data than always
rounding up or down."
This commit is contained in:
Tim Graham
2024-12-18 06:50:48 -05:00
committed by GitHub
parent 20f9f61805
commit bb6114ce50
3 changed files with 7 additions and 2 deletions

View File

@@ -112,7 +112,8 @@ class RoundTests(TestCase):
IntegerModel.objects.create(normal=365)
obj = IntegerModel.objects.annotate(normal_round=Round("normal", -1)).first()
self.assertIsInstance(obj.normal_round, int)
self.assertEqual(obj.normal_round, 370)
expected = 360 if connection.features.rounds_to_even else 370
self.assertEqual(obj.normal_round, expected)
def test_transform(self):
with register_lookup(DecimalField, Round):