Refs #24833 -- Forwardported some of "Fixed Case expressions with exclude()."

Partial forwardport of 469f1e362b from stable/1.8.x
as the issue was already fixed in master.
This commit is contained in:
Andriy Sokolovskiy 2015-06-05 11:10:51 +01:00 committed by Tim Graham
parent cbe4efcbc1
commit 286d0e6ab1
3 changed files with 21 additions and 6 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(