|
@@ -252,6 +252,18 @@ class CaseExpressionTests(TestCase):
|
|
|
transform=attrgetter('integer', 'test')
|
|
|
)
|
|
|
|
|
|
+ def test_annotate_values_not_in_order_by(self):
|
|
|
+ self.assertEqual(
|
|
|
+ list(CaseTestModel.objects.annotate(test=Case(
|
|
|
+ When(integer=1, then=Value('one')),
|
|
|
+ When(integer=2, then=Value('two')),
|
|
|
+ When(integer=3, then=Value('three')),
|
|
|
+ default=Value('other'),
|
|
|
+ output_field=models.CharField(),
|
|
|
+ )).order_by('test').values_list('integer', flat=True)),
|
|
|
+ [1, 4, 3, 3, 3, 2, 2]
|
|
|
+ )
|
|
|
+
|
|
|
def test_combined_expression(self):
|
|
|
self.assertQuerysetEqual(
|
|
|
CaseTestModel.objects.annotate(
|