From f32ee6d0ec31580cd1ab55e64ff4fb2122aba420 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 28 Apr 2017 06:07:28 +0200 Subject: [PATCH] Refs #6767 -- Added test for fetching decimal values without rounding error on Oracle. --- tests/model_fields/test_decimalfield.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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.