From 76aecfbc4b49f5ab0613cccff1df6fab03253fab Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 23 Mar 2013 16:09:56 +0100 Subject: Fixed #9055 -- Standardized behaviour of parameter escaping in db cursors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, depending on the database backend or the cursor type, you'd need to double the percent signs in the query before passing it to cursor.execute. Now cursor.execute consistently need percent doubling whenever params argument is not None (placeholder substitution will happen). Thanks Thomas Güttler for the report and Walter Doekes for his work on the patch. --- django/db/backends/sqlite3/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'django/db/backends/sqlite3') diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index f70c3872a8..ead325a33b 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -433,7 +433,9 @@ class SQLiteCursorWrapper(Database.Cursor): This fixes it -- but note that if you want to use a literal "%s" in a query, you'll need to use "%%s". """ - def execute(self, query, params=()): + def execute(self, query, params=None): + if params is None: + return Database.Cursor.execute(self, query) query = self.convert_query(query) return Database.Cursor.execute(self, query, params) -- cgit v1.3