summaryrefslogtreecommitdiff
path: root/tests/annotations
diff options
context:
space:
mode:
authorLex Berezhny <lex@damoti.com>2017-01-31 18:45:55 -0500
committerTim Graham <timograham@gmail.com>2017-01-31 18:45:55 -0500
commitac5f886c5610a6bca26dab10170b445d1e9df450 (patch)
tree5bfdc9b29abb3de8dcab3d573410e41d2902cf55 /tests/annotations
parent84126f2789542b7dfe68ac6cb3a088e3a072db0d (diff)
downloaddjango-ac5f886c5610a6bca26dab10170b445d1e9df450.tar.gz
Fixed #27800 -- Fixed QuerySet.annotate(Length(...)).distinct() crash.
Diffstat (limited to 'tests/annotations')
-rw-r--r--tests/annotations/tests.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index 65886b2063..b149ddf46c 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -6,7 +6,7 @@ from django.db.models import (
BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, Func,
IntegerField, NullBooleanField, Q, Sum, Value,
)
-from django.db.models.functions import Lower
+from django.db.models.functions import Length, Lower
from django.test import TestCase, skipUnlessDBFeature
from .models import (
@@ -205,6 +205,11 @@ class NonAggregateAnnotationTestCase(TestCase):
).distinct('test_alias')
self.assertEqual(len(people2), 1)
+ lengths = Employee.objects.annotate(
+ name_len=Length('first_name'),
+ ).distinct('name_len').values_list('name_len', flat=True)
+ self.assertSequenceEqual(lengths, [3, 7, 8])
+
def test_filter_annotation(self):
books = Book.objects.annotate(
is_book=Value(1, output_field=IntegerField())