1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[1.8.x] Fixed #24833 -- Fixed Case expressions with exclude().

This commit is contained in:
Andriy Sokolovskiy
2015-06-05 11:04:45 +01:00
committed by Tim Graham
parent 7dcfbb2ef3
commit 469f1e362b
4 changed files with 39 additions and 8 deletions

View File

@@ -240,6 +240,18 @@ class CaseExpressionTests(TestCase):
transform=itemgetter('integer', 'max', 'test')
)
def test_annotate_exclude(self):
self.assertQuerysetEqual(
CaseTestModel.objects.annotate(test=Case(
When(integer=1, then=Value('one')),
When(integer=2, then=Value('two')),
default=Value('other'),
output_field=models.CharField(),
)).exclude(test='other').order_by('pk'),
[(1, 'one'), (2, 'two'), (2, 'two')],
transform=attrgetter('integer', 'test')
)
def test_combined_expression(self):
self.assertQuerysetEqual(
CaseTestModel.objects.annotate(