diff options
| author | VIZZARD-X <vigneshanandmay13@gmail.com> | 2026-01-16 19:01:23 +0530 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-01-20 10:42:28 -0500 |
| commit | e083c62f51f408aaacbf55684daf83c78d0d1bc1 (patch) | |
| tree | 4d681dee94e4f61e0979498739aad9da924a92da /tests/expressions | |
| parent | e5cbb8b4be04797deedc775a5143b5035e7dd3b7 (diff) | |
Fixed #36030 -- Fixed precision loss in division of Decimal literals on SQLite.
Thanks Bob Kline for the review.
Diffstat (limited to 'tests/expressions')
| -rw-r--r-- | tests/expressions/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
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( |
