﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5018	Add SQL_DEBUG option that shows SQL queries being executed	Yuri Baburov <burchik@…>	Adrian Holovaty	"This should be self-explanatory
{{{
Index: D:/web/projects/django-newforms/django/db/backends/util.py
===================================================================
--- D:/web/projects/django-newforms/django/db/backends/util.py	(revision 5753)
+++ D:/web/projects/django-newforms/django/db/backends/util.py	(working copy)
@@ -19,6 +19,15 @@
             return self.cursor.execute(sql, params)
         finally:
             stop = time()
+            from django.conf import settings
+            # If params was a list, convert it to a tuple, because string
+            # formatting with '%' only works with tuples or dicts.
+            if not isinstance(params, (tuple, dict)):
+                params = tuple(params)
+            if getattr(settings, 'SQL_DEBUG', False):
+                if not isinstance(params, (tuple, dict)):
+                    params = tuple(params)
+                print '>', sql % params
             self.db.queries.append({
                 'sql': smart_unicode(sql) % convert_args(params),
                 'time': ""%.3f"" % (stop - start),
}}}"		closed	Database layer (models, ORM)	dev		wontfix	SQL_DEBUG, SQL, queries, show, development, server		Unreviewed	1	0	0	1	0	0
