Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review: internationalize the executemany label
Use ngettext for the repeat count and move the changelog entry into Pending,
which a release moved out from under it.
  • Loading branch information
alliasgher committed Aug 16, 2026
commit aead842d6bfc6ff8a22082f11628b65860a20aef
10 changes: 8 additions & 2 deletions debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import django.test.testcases
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import gettext as _, ngettext

from debug_toolbar import settings as dt_settings
from debug_toolbar.sanitize import force_str
Expand Down Expand Up @@ -227,8 +228,13 @@ def _record(self, method, sql, params, *, many=False):
try:
times = len(params)
except TypeError:
times = "?"
display_sql = f"{times} times: {sql}"
display_sql = _("? times: %(sql)s") % {"sql": sql}
else:
display_sql = ngettext(
"%(count)d time: %(sql)s",
"%(count)d times: %(sql)s",
times,
) % {"count": times, "sql": sql}
else:
display_sql = self._last_executed_query(sql, params)

Expand Down
6 changes: 3 additions & 3 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Pending
* Updated the example screenshot.
* Updated the screenshot capture logic to find the toolbar elements in the
shadow DOM.
* Fixed ``cursor.executemany()`` raising from the SQL panel instead of being
recorded. The statement is now shown as ``N times: <sql>``, matching
Django's own debug cursor.

7.1.1 (2026-08-14)
------------------
Expand All @@ -48,9 +51,6 @@ Pending
* Stopped the history panel buttons from submitting their form when clicked
before the panel script has loaded, which navigated away from the page.
* Added support for Django 6.1.
* Fixed ``cursor.executemany()`` raising from the SQL panel instead of being
recorded. The statement is now shown as ``N times: <sql>``, matching
Django's own debug cursor.

7.0.0 (2026-06-17)
------------------
Expand Down
16 changes: 16 additions & 0 deletions tests/panels/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ def test_executemany(self):
self.assertTrue(query["many"])
self.assertEqual(Binary.objects.count(), 2)

def test_executemany_singular(self):
"""A single param set uses the singular form."""
self.assertEqual(len(self.panel._queries), 0)

with connection.cursor() as cursor:
cursor.executemany(
"INSERT INTO tests_binary (field) VALUES (%s)", [(b"one",)]
)

self.assertEqual(len(self.panel._queries), 1)
self.assertEqual(
self.panel._queries[0]["sql"],
"1 time: INSERT INTO tests_binary (field) VALUES (%s)",
)
self.assertEqual(Binary.objects.count(), 1)

def test_executemany_with_empty_param_list(self):
"""An empty param list runs no statement but must still not raise."""
self.assertEqual(len(self.panel._queries), 0)
Expand Down