1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #23460 -- Added literal %s support to extra() QuerySets.

This commit is contained in:
Matt Robenolt
2014-09-10 07:23:58 +00:00
committed by Tim Graham
parent 17557d068c
commit ef5f9b6ae8
4 changed files with 26 additions and 6 deletions

View File

@@ -1655,6 +1655,21 @@ class Queries5Tests(TestCase):
['<Note: n1>', '<Note: n2>']
)
def test_extra_select_literal_percent_s(self):
# Allow %%s to escape select clauses
self.assertEqual(
Note.objects.extra(select={'foo': "'%%s'"})[0].foo,
'%s'
)
self.assertEqual(
Note.objects.extra(select={'foo': "'%%s bar %%s'"})[0].foo,
'%s bar %s'
)
self.assertEqual(
Note.objects.extra(select={'foo': "'bar %%s'"})[0].foo,
'bar %s'
)
class SelectRelatedTests(TestCase):
def test_tickets_3045_3288(self):