From e083c62f51f408aaacbf55684daf83c78d0d1bc1 Mon Sep 17 00:00:00 2001 From: VIZZARD-X Date: Fri, 16 Jan 2026 19:01:23 +0530 Subject: Fixed #36030 -- Fixed precision loss in division of Decimal literals on SQLite. Thanks Bob Kline for the review. --- tests/expressions/tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 981d84e9e8..02126fa896 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -137,6 +137,16 @@ class BasicExpressionsTests(TestCase): ) self.assertEqual(companies["result"], 2395) + def test_decimal_division_literal_value(self): + """ + Division with a literal Decimal value preserves precision. + """ + num = Number.objects.create(integer=2) + obj = Number.objects.annotate( + val=F("integer") / Value(Decimal("3.0"), output_field=DecimalField()) + ).get(pk=num.pk) + self.assertAlmostEqual(obj.val, Decimal("0.6667"), places=4) + def test_annotate_values_filter(self): companies = ( Company.objects.annotate( -- cgit v1.3