summaryrefslogtreecommitdiff
path: root/tests/expressions_case
diff options
context:
space:
mode:
authorAndriy Sokolovskiy <me@asokolovskiy.com>2015-06-05 11:10:51 +0100
committerTim Graham <timograham@gmail.com>2015-06-05 11:21:31 -0400
commit286d0e6ab1e54906007fda86b6cb6deb26c6deb2 (patch)
tree79220390d768977f3eb3b4d072e9ffdfe1bd37c6 /tests/expressions_case
parentcbe4efcbc13ad402bf1f1a94b02a8ec93f20327d (diff)
downloaddjango-286d0e6ab1e54906007fda86b6cb6deb26c6deb2.tar.gz
Refs #24833 -- Forwardported some of "Fixed Case expressions with exclude()."
Partial forwardport of 469f1e362bb9670b174b37da9edd4631aff7badb from stable/1.8.x as the issue was already fixed in master.
Diffstat (limited to 'tests/expressions_case')
-rw-r--r--tests/expressions_case/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py
index 6d35be8865..31ec88c7ec 100644
--- a/tests/expressions_case/tests.py
+++ b/tests/expressions_case/tests.py
@@ -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(