Opened 9 years ago

Closed 8 years ago

#2913 closed defect (fixed)

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

Reported by: artdent@… Owned by: adrian
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: UI/UX:

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@… 9 years ago.
Patch for util.py

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by artdent@…

Patch for util.py

comment:1 Changed 9 years ago by artdent@…

  • Summary changed from Logic error re sql param interpolation in CursorDebugWrapper.execute to [patch] Logic error re sql param interpolation in CursorDebugWrapper.execute

Changing subject to reflect the existence of a patch

comment:2 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

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