mirror of
https://github.com/django/django.git
synced 2025-08-18 01:30:42 +00:00
[1.11.x] Fixed #27800 -- Fixed QuerySet.annotate(Length(...)).distinct() crash.
Backport of ac5f886c56
from master
This commit is contained in:
parent
8afe790df9
commit
d43f847847
3 changed files with 13 additions and 2 deletions
|
@ -8,7 +8,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 django.utils import six
|
||||
|
||||
|
@ -208,6 +208,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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue