-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
I have a sql query containing ... WHERE id = ANY(%s) and the param being a list, e.g. [1, 2].
Adapted, the query looks like id = ANY('{1,2}'::int2[]) , but in the SQL panel, it shows up as id = ANY('[1,2]'). This is due to the parameters being quoted already before being passed to mogrify. Dropping the extra quoting step, the query shows up correctly in the SQL panel.
diff --git a/debug_toolbar/panels/sql/tracking.py b/debug_toolbar/panels/sql/tracking.py
index 0c53dc2c..bcff5905 100644
--- a/debug_toolbar/panels/sql/tracking.py
+++ b/debug_toolbar/panels/sql/tracking.py
@@ -115,15 +115,6 @@ class NormalCursorMixin(DjDTCursorWrapperMixin):
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
@@ -157,9 +148,7 @@ class NormalCursorMixin(DjDTCursorWrapperMixin):
# 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
Note that I've tested only with psycopg2/3, I don't know if other backends require the extra quoting.
Metadata
Metadata
Assignees
Labels
No labels