summaryrefslogtreecommitdiff
path: root/tests/annotations
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-12-22 05:50:56 +0500
committerTim Graham <timograham@gmail.com>2017-12-21 19:50:56 -0500
commitebc4ee3369694e6dca5cf216d4176bdefd930fd6 (patch)
treedb7595fae1fe774c02fea051d69b6eb0efef4333 /tests/annotations
parentad9390bba27cb41da92f734db4d0e36ef3dfc58f (diff)
downloaddjango-ebc4ee3369694e6dca5cf216d4176bdefd930fd6.tar.gz
Refs #23941 -- Prevented incorrect rounding of DecimalField annotations on SQLite.
Diffstat (limited to 'tests/annotations')
-rw-r--r--tests/annotations/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index aaf56e79ef..d2e2214db8 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -244,6 +244,20 @@ class NonAggregateAnnotationTestCase(TestCase):
sum_rating=Sum('rating')
).filter(sum_rating=F('nope')))
+ def test_decimal_annotation(self):
+ salary = Decimal(10) ** -Employee._meta.get_field('salary').decimal_places
+ Employee.objects.create(
+ first_name='Max',
+ last_name='Paine',
+ store=Store.objects.first(),
+ age=23,
+ salary=salary,
+ )
+ self.assertEqual(
+ Employee.objects.annotate(new_salary=F('salary') / 10).get().new_salary,
+ salary / 10,
+ )
+
def test_filter_decimal_annotation(self):
qs = Book.objects.annotate(new_price=F('price') + 1).filter(new_price=Decimal(31)).values_list('new_price')
self.assertEqual(qs.get(), (Decimal(31),))