Opened 16 years ago
Closed 16 years ago
#10851 closed (duplicate)
mysql CursorWrapper.execute has different prototype than CursorDebugWrapper
Reported by: | Walter Doekes | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | walter@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
/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.
Attachments (1)
Change History (2)
by , 16 years ago
Attachment: | mysql_default_params_tuple.diff added |
---|
comment:1 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#9055 is already open for this and covers all backends, not just MySQL.
replace args=None with params=() in MySQL CursorWrapper