django-debug-toolbar/django-debug-toolbar — pull request #298 by jdnier (2012-07-10 20:41:54+00:00)
Title: _quote_params fails when params is None.

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:

: 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: https://github.com/django-debug-toolbar/django-debug-toolbar/commit/d6a3b17b15c8bc9aa251c3cf07e5330c4a2dcdb1

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

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

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