mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
committed by
Tim Graham
parent
cbe4efcbc1
commit
286d0e6ab1
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user