Skip to content

Commit

Permalink
[1.3.X] Fixed #13648 - '%s' escaping support for sqlite3 regression.
Browse files Browse the repository at this point in the history
Thanks to master for the report and initial patch, and salgado and others
for work on the patch.

Backport of [16209] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16210 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed May 10, 2011
1 parent 7fd113e commit 5c08cda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/backends/sqlite3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def close(self):
if self.settings_dict['NAME'] != ":memory:":
BaseDatabaseWrapper.close(self)

FORMAT_QMARK_REGEX = re.compile(r'(?![^%])%s')
FORMAT_QMARK_REGEX = re.compile(r'(?<!%)%s')

class SQLiteCursorWrapper(Database.Cursor):
"""
Expand Down
14 changes: 14 additions & 0 deletions tests/regressiontests/backends/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ def receiver(sender, connection, **kwargs):
self.assertTrue(data == {})


class EscapingChecks(TestCase):

@unittest.skipUnless(connection.vendor == 'sqlite',
"This is a sqlite-specific issue")
def test_parameter_escaping(self):
#13648: '%s' escaping support for sqlite3
cursor = connection.cursor()
response = cursor.execute(
"select strftime('%%s', date('now'))").fetchall()[0][0]
self.assertNotEqual(response, None)
# response should be an non-zero integer
self.assertTrue(int(response))


class BackendTestCase(TestCase):
def test_cursor_executemany(self):
#4896: Test cursor.executemany
Expand Down

0 comments on commit 5c08cda

Please sign in to comment.