mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +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:
parent
cbe4efcbc1
commit
286d0e6ab1
3 changed files with 21 additions and 6 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue