From 3d64e7e63fe41915a5a2916b4ca066a84d355ca7 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Tue, 7 Mar 2006 17:57:15 +0000 Subject: [PATCH] magic-removal: fixed #1475 - debug mode now logs failsed queries, as well (thanks, cmlenz) git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2500 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/util.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/django/db/backends/util.py b/django/db/backends/util.py index 01503bf086..5c7302e1c9 100644 --- a/django/db/backends/util.py +++ b/django/db/backends/util.py @@ -8,23 +8,25 @@ class CursorDebugWrapper: def execute(self, sql, params=[]): start = time() - result = self.cursor.execute(sql, params) - stop = time() - self.db.queries.append({ - 'sql': sql % tuple(params), - 'time': "%.3f" % (stop - start), - }) - return result + try: + return self.cursor.execute(sql, params) + finally: + stop = time() + self.db.queries.append({ + 'sql': sql % tuple(params), + 'time': "%.3f" % (stop - start), + }) def executemany(self, sql, param_list): start = time() - result = self.cursor.executemany(sql, param_list) - stop = time() - self.db.queries.append({ - 'sql': 'MANY: ' + sql + ' ' + str(tuple(param_list)), - 'time': "%.3f" % (stop - start), - }) - return result + try: + return self.cursor.executemany(sql, param_list) + finally: + stop = time() + self.db.queries.append({ + 'sql': 'MANY: ' + sql + ' ' + str(tuple(param_list)), + 'time': "%.3f" % (stop - start), + }) def __getattr__(self, attr): if self.__dict__.has_key(attr):