﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10851	mysql CursorWrapper.execute has different prototype than CursorDebugWrapper	Walter Doekes	nobody	"{{{
/usr/share/python-support/python-django/django/db/backends/mysql/base.py:
class CursorWrapper(object):
    def execute(self, query, args=None):
    def executemany(self, query, args):
/usr/share/python-support/python-django/django/db/backends/sqlite3/base.py:
class SQLiteCursorWrapper(Database.Cursor):
    def execute(self, query, params=()):
    def executemany(self, query, param_list):
/usr/share/python-support/python-django/django/db/backends/postgresql/base.py:
class UnicodeCursorWrapper(object):
    def execute(self, sql, params=()):
    def executemany(self, sql, param_list):
/usr/share/python-support/python-django/django/db/backends/util.py:
class CursorDebugWrapper(object):
    def execute(self, sql, params=()):
    def executemany(self, sql, param_list):
}}}

If you're in DEBUG-mode, you get the DebugWrapper and an empty tuple as default parameter. For queries without parameters this means that you have to escape percent signs (using the double-percent).

When you switch to !DEBUG, you get the regular CursorWrapper that gets a None as default. Now parameter-less queries do not want the percent-sign escaped.

The fix: change
{{{
    def execute(self, query, args=None):
}}}
to
{{{
    def execute(self, query, args=()):
}}}
in /usr/share/python-support/python-django/django/db/backends/mysql/base.py


Regards,
Walter Doekes
OSSO B.V.
"		closed	Database layer (models, ORM)	dev		duplicate		walter@…	Unreviewed	1	0	0	0	0	0
