summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-02-11 16:38:02 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2015-02-12 08:53:03 +1100
commita6ea62aeafd4512f6d13aeda908f7622776a4537 (patch)
tree27059733fa267e00d7d2bd4058d2f8aef88e2ca0 /tests/aggregation
parent343c0875338128dad162d4806fe908fb31404d14 (diff)
[1.8.x] Refs #14030 -- Improved expression support for python values
Backport of e2d6e14662d780383e18066a3182155fb5b7747b from master
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 9282c7e10c..bc3929d98e 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -8,7 +8,7 @@ from django.core.exceptions import FieldError
from django.db import connection
from django.db.models import (
F, Aggregate, Avg, Count, DecimalField, FloatField, Func, IntegerField,
- Max, Min, Sum, Value,
+ Max, Min, Sum,
)
from django.test import TestCase, ignore_warnings
from django.test.utils import Approximate, CaptureQueriesContext
@@ -706,14 +706,14 @@ class ComplexAggregateTestCase(TestCase):
Book.objects.aggregate(fail=F('price'))
def test_nonfield_annotation(self):
- book = Book.objects.annotate(val=Max(Value(2, output_field=IntegerField())))[0]
+ book = Book.objects.annotate(val=Max(2, output_field=IntegerField()))[0]
self.assertEqual(book.val, 2)
- book = Book.objects.annotate(val=Max(Value(2), output_field=IntegerField()))[0]
+ book = Book.objects.annotate(val=Max(2, output_field=IntegerField()))[0]
self.assertEqual(book.val, 2)
def test_missing_output_field_raises_error(self):
with six.assertRaisesRegex(self, FieldError, 'Cannot resolve expression type, unknown output_field'):
- Book.objects.annotate(val=Max(Value(2)))[0]
+ Book.objects.annotate(val=Max(2))[0]
def test_annotation_expressions(self):
authors = Author.objects.annotate(combined_ages=Sum(F('age') + F('friends__age'))).order_by('name')
@@ -772,7 +772,7 @@ class ComplexAggregateTestCase(TestCase):
with six.assertRaisesRegex(self, TypeError, 'Complex aggregates require an alias'):
Author.objects.aggregate(Sum('age') / Count('age'))
with six.assertRaisesRegex(self, TypeError, 'Complex aggregates require an alias'):
- Author.objects.aggregate(Sum(Value(1)))
+ Author.objects.aggregate(Sum(1))
def test_aggregate_over_complex_annotation(self):
qs = Author.objects.annotate(