diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2011-05-10 12:28:29 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2011-05-10 12:28:29 +0000 |
| commit | 5c08cda6113cf65ca489385bdbece43cd8b1913c (patch) | |
| tree | 54e12bc34ed6d696429f5c37815538c7c2cf89b7 | |
| parent | 7fd113e6184c1602e4ad6d6d7a92c78a158e78ff (diff) | |
[1.3.X] Fixed #13648 - '%s' escaping support for sqlite3 regression.
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
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/backends/tests.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 8344bad2a0..2de2818100 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -220,7 +220,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): 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): """ diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index efa3e0c7d3..fc2a973ab1 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -194,6 +194,20 @@ class ConnectionCreatedSignalTest(TestCase): 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 |
