_quote_params fails when params is None. #298

wants to merge 10 commits into


None yet
3 participants

jdnier commented Jul 10, 2012

The method NormalCursorWrapper._quote_params(params) in debug_toolbar/utils/tracking/db.py does not handle the case where params is None, resulting in the following exception:

<type 'exceptions.TypeError'>: argument 2 to map() must support iteration

In a few places in our Django apps, we execute manual queries a la

django.db.connection.cursor.execute(sql, params)

It has always been valid to pass None in for params. Unfortunately, _quote_params doesn't deal with this case. This is only a problem when debug toolbar is activated.

I have not tried using debug toolbar for a couple years, so I'm just noticing the problem. _quote_params was added 9 months ago here: d6a3b17

FWIW, my database connector is psycopg2. It's default value for params is None, so passing None thorough is reasonable behavior, I think.

>>> help(cursor.execute)       
Help on built-in function execute:

    execute(query, vars=None) -- Execute query with bound vars.

I have a same problem. This patch is right.

jdnier commented Sep 6, 2012

This is a very simple fix. Would you prefer a patch?

@jdnier jdnier closed this May 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment