summaryrefslogtreecommitdiff
path: root/tests/model_fields/test_decimalfield.py
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 21:57:41 -1000
commit6fd6d8383f48ea2fe4e058725fa30529a083e9a5 (patch)
tree3837e18f267889cd21ecbb8fedf53653f49f5ac7 /tests/model_fields/test_decimalfield.py
parent30a389bd7795016d7f48bcda997e5dea5116f9bb (diff)
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.
Diffstat (limited to 'tests/model_fields/test_decimalfield.py')
-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'))