Opened 18 years ago

Closed 17 years ago

#2913 closed defect (fixed)

[patch] Logic error re sql param interpolation in CursorDebugWrapper.execute

Reported by: artdent@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: 0.95
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The relevant code, inside db/backends/util.py, is as follows:

if not isinstance(params, (tuple, dict)):
    params = tuple(params)
self.db.queries.append({
    'sql': sql % tuple(params),
    'time': "%.3f" % (stop - start),
})

The second instance in that code of converting params into a tuple is erroneous (if params is a dictionary, it should not be converted into a tuple). As a result, string interpolation using the %(name)s syntax fails in debug mode.

Attachments (1)

patch (95 bytes ) - added by artdent@… 18 years ago.
Patch for util.py

Download all attachments as: .zip

Change History (3)

by artdent@…, 18 years ago

Attachment: patch added

Patch for util.py

comment:1 by artdent@…, 18 years ago

Summary: Logic error re sql param interpolation in CursorDebugWrapper.execute[patch] Logic error re sql param interpolation in CursorDebugWrapper.execute

Changing subject to reflect the existence of a patch

comment:2 by Jacob, 17 years ago

Resolution: fixed
Status: newclosed

(In [4045]) Fixed #2913: CursorDebugWrapper no longer double-tuple-izes parameters. Thanks, artdent@…

Note: See TracTickets for help on using tickets.
Back to Top