Fixed #28915 -- Prevented SQLite from truncating trailing zeros in the fractional part of DecimalField.

This reverts commit a146b65628 and adds
a test for the regression.
This commit is contained in:
Sergey Fedoseev 2017-12-12 19:07:01 +05:00 committed by Tim Graham
parent 30a389bd77
commit 6fd6d8383f
3 changed files with 12 additions and 6 deletions

View file

@ -81,3 +81,9 @@ class DecimalFieldTests(TestCase):
expected_message = validators.DecimalValidator.messages['max_whole_digits'] % {'max': 2}
with self.assertRaisesMessage(ValidationError, expected_message):
field.clean(Decimal('999'), None)
def test_roundtrip_with_trailing_zeros(self):
"""Trailing zeros in the fractional part aren't truncated."""
obj = Foo.objects.create(a='bar', d=Decimal('8.320'))
obj.refresh_from_db()
self.assertEqual(obj.d.compare_total(Decimal('8.320')), Decimal('0'))