summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-12-12 19:07:01 +0500
committerTim Graham <timograham@gmail.com>2017-12-12 22:01:25 -1000
commit0f7ca1e8786ac04ad819a147a69ab5d4054e4d39 (patch)
treed3d0054da6184f5e2b3e1b9668b872a8760b6008 /tests/model_fields
parent9f39f202abea4daf37f4ad3f9e4c272fd9e4d185 (diff)
[2.0.x] Fixed #28915 -- Prevented SQLite from truncating trailing zeros in the fractional part of DecimalField.
This reverts commit a146b65628e702a9a3ed5be21542ca45366fbb29 and adds a test for the regression. Backport of 6fd6d8383f48ea2fe4e058725fa30529a083e9a5 from master
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_decimalfield.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/model_fields/test_decimalfield.py b/tests/model_fields/test_decimalfield.py
index c8851c5d94..893d529ed5 100644
--- a/tests/model_fields/test_decimalfield.py
+++ b/tests/model_fields/test_decimalfield.py
@@ -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'))