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

Fixed #32793 -- Fixed loss of precision for temporal operations with DecimalFields on MySQL.

Regression in 1e38f1191d.

Thanks Mohsen Tamiz for the report.
This commit is contained in:
Mariusz Felisiak
2021-06-01 15:11:42 +02:00
committed by GitHub
parent a0410ffe8f
commit e703b152c6
4 changed files with 15 additions and 1 deletions

View File

@@ -1194,6 +1194,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