1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

[3.2.x] Fixed #32793 -- Fixed loss of precision for temporal operations with DecimalFields on MySQL.

Regression in 1e38f1191d.

Thanks Mohsen Tamiz for the report.
Backport of e703b152c6 from main
This commit is contained in:
Mariusz Felisiak
2021-06-01 15:11:42 +02:00
parent b2ff1655fc
commit 94675a7633
4 changed files with 15 additions and 1 deletions

View File

@@ -1176,6 +1176,13 @@ class ExpressionsNumericTests(TestCase):
self.assertEqual(Number.objects.get(pk=n.pk).integer, 10)
self.assertEqual(Number.objects.get(pk=n.pk).float, Approximate(256.900, places=3))
def test_decimal_expression(self):
n = Number.objects.create(integer=1, decimal_value=Decimal('0.5'))
n.decimal_value = F('decimal_value') - Decimal('0.4')
n.save()
n.refresh_from_db()
self.assertEqual(n.decimal_value, Decimal('0.1'))
class ExpressionOperatorTests(TestCase):
@classmethod