Code

Ticket #7058: test_case_sql.diff

File test_case_sql.diff, 656 bytes (added by ikelly, 6 years ago)
Line 
1Index: regressiontests/queries/models.py
2===================================================================
3--- regressiontests/queries/models.py   (revision 7438)
4+++ regressiontests/queries/models.py   (working copy)
5@@ -473,7 +473,7 @@
6 >>> Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank'])
7 [<Ranking: 1: a3>, <Ranking: 2: a2>, <Ranking: 3: a1>]
8 
9->>> qs = Ranking.objects.extra(select={'good': 'rank > 2'})
10+>>> qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'})
11 >>> [o.good for o in qs.extra(order_by=('-good',))] == [True, False, False]
12 True
13 >>> qs.extra(order_by=('-good', 'id'))