Skip to content

Commit 06c42d9

Browse files
authored
do not quote SQL params before passing them to mogrify (#1832)
1 parent 5d5d459 commit 06c42d9

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

debug_toolbar/panels/sql/tracking.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,6 @@ class NormalCursorMixin(DjDTCursorWrapperMixin):
109109
Wraps a cursor and logs queries.
110110
"""
111111

112-
def _quote_expr(self, element):
113-
if isinstance(element, str):
114-
return "'%s'" % element.replace("'", "''")
115-
else:
116-
return repr(element)
117-
118-
def _quote_params(self, params):
119-
if not params:
120-
return params
121-
if isinstance(params, dict):
122-
return {key: self._quote_expr(value) for key, value in params.items()}
123-
if isinstance(params, tuple):
124-
return tuple(self._quote_expr(p) for p in params)
125-
return [self._quote_expr(p) for p in params]
126-
127112
def _decode(self, param):
128113
if PostgresJson and isinstance(param, PostgresJson):
129114
# psycopg3
@@ -157,9 +142,7 @@ def _last_executed_query(self, sql, params):
157142
# process during the .last_executed_query() call.
158143
self.db._djdt_logger = None
159144
try:
160-
return self.db.ops.last_executed_query(
161-
self.cursor, sql, self._quote_params(params)
162-
)
145+
return self.db.ops.last_executed_query(self.cursor, sql, params)
163146
finally:
164147
self.db._djdt_logger = self.logger
165148

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Pending
55
-------
66

77
* Removed outdated third-party panels from the list.
8+
* Avoided the unnecessary work of recursively quoting SQL parameters.
89

910
4.2.0 (2023-08-10)
1011
------------------

0 commit comments

Comments
 (0)