summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-04-28 06:07:28 +0200
committerGitHub <noreply@github.com>2017-04-28 06:07:28 +0200
commitf32ee6d0ec31580cd1ab55e64ff4fb2122aba420 (patch)
tree5d11a85681ad11996ca5774a3ee79546fae7ae54
parent620e9dd31a2146d70de740f96a8cb9a6db054fc7 (diff)
Refs #6767 -- Added test for fetching decimal values without rounding error on Oracle.
-rw-r--r--tests/model_fields/test_decimalfield.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/model_fields/test_decimalfield.py b/tests/model_fields/test_decimalfield.py
index 8ba7562618..944ce5620d 100644
--- a/tests/model_fields/test_decimalfield.py
+++ b/tests/model_fields/test_decimalfield.py
@@ -1,8 +1,10 @@
+import unittest
+
from decimal import Decimal
from django.core import validators
from django.core.exceptions import ValidationError
-from django.db import models
+from django.db import connection, models
from django.test import TestCase
from .models import BigD, Foo
@@ -49,6 +51,12 @@ class DecimalFieldTests(TestCase):
bd = BigD.objects.get(pk=bd.pk)
self.assertEqual(bd.d, Decimal('12.9'))
+ @unittest.skipIf(connection.vendor == 'sqlite', 'SQLite stores values rounded to 15 significant digits.')
+ def test_fetch_from_db_without_float_rounding(self):
+ big_decimal = BigD.objects.create(d=Decimal('.100000000000000000000000000005'))
+ big_decimal.refresh_from_db()
+ self.assertEqual(big_decimal.d, Decimal('.100000000000000000000000000005'))
+
def test_lookup_really_big_value(self):
"""
Really big values can be used in a filter statement.