Skip to content

_quote_params fails when params is None. #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed

_quote_params fails when params is None. #298

wants to merge 10 commits into from

Conversation

jdnier
Copy link

@jdnier 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(...)
    execute(query, vars=None) -- Execute query with bound vars.

@leekchan
Copy link

I have a same problem. This patch is right.

@jdnier
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants