[2.0.x] Refs #29451 -- Fixed invalid SQL on MySQL in queries tests.
Backport of c4f099de1d
from master
This commit is contained in:
parent
83986af95d
commit
243f07bbb3
|
@ -1609,7 +1609,8 @@ class Queries5Tests(TestCase):
|
|||
['<Ranking: 1: a3>', '<Ranking: 2: a2>', '<Ranking: 3: a1>']
|
||||
)
|
||||
|
||||
qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'})
|
||||
sql = 'case when %s > 2 then 1 else 0 end' % connection.ops.quote_name('rank')
|
||||
qs = Ranking.objects.extra(select={'good': sql})
|
||||
self.assertEqual(
|
||||
[o.good for o in qs.extra(order_by=('-good',))],
|
||||
[True, False, False]
|
||||
|
@ -1630,7 +1631,8 @@ class Queries5Tests(TestCase):
|
|||
def test_ticket7256(self):
|
||||
# An empty values() call includes all aliases, including those from an
|
||||
# extra()
|
||||
qs = Ranking.objects.extra(select={'good': 'case when rank > 2 then 1 else 0 end'})
|
||||
sql = 'case when %s > 2 then 1 else 0 end' % connection.ops.quote_name('rank')
|
||||
qs = Ranking.objects.extra(select={'good': sql})
|
||||
dicts = qs.values().order_by('id')
|
||||
for d in dicts:
|
||||
del d['id']
|
||||
|
|
Loading…
Reference in New Issue