Skip to content

Commit

Permalink
do not quote SQL params before passing them to mogrify (#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoschnick committed Sep 26, 2023
1 parent 5d5d459 commit 06c42d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
19 changes: 1 addition & 18 deletions debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,6 @@ class NormalCursorMixin(DjDTCursorWrapperMixin):
Wraps a cursor and logs queries.
"""

def _quote_expr(self, element):
if isinstance(element, str):
return "'%s'" % element.replace("'", "''")
else:
return repr(element)

def _quote_params(self, params):
if not params:
return params
if isinstance(params, dict):
return {key: self._quote_expr(value) for key, value in params.items()}
if isinstance(params, tuple):
return tuple(self._quote_expr(p) for p in params)
return [self._quote_expr(p) for p in params]

def _decode(self, param):
if PostgresJson and isinstance(param, PostgresJson):
# psycopg3
Expand Down Expand Up @@ -157,9 +142,7 @@ def _last_executed_query(self, sql, params):
# process during the .last_executed_query() call.
self.db._djdt_logger = None
try:
return self.db.ops.last_executed_query(
self.cursor, sql, self._quote_params(params)
)
return self.db.ops.last_executed_query(self.cursor, sql, params)
finally:
self.db._djdt_logger = self.logger

Expand Down
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Pending
-------

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

4.2.0 (2023-08-10)
------------------
Expand Down

0 comments on commit 06c42d9

Please sign in to comment.