Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Skip logging queries#296

Open
artamonovkirill wants to merge 1 commit intogoogle:mastergoogle/sqlcommenter:masterfrom
artamonovkirill:patch-1artamonovkirill/sqlcommenter:patch-1Copy head branch name to clipboard
Open

Skip logging queries#296
artamonovkirill wants to merge 1 commit intogoogle:mastergoogle/sqlcommenter:masterfrom
artamonovkirill:patch-1artamonovkirill/sqlcommenter:patch-1Copy head branch name to clipboard

Conversation

@artamonovkirill
Copy link

@artamonovkirill artamonovkirill commented Jan 8, 2026

Fixes #287

CursorDebugWrapper already adds an entry to the queries_log post-execution: https://github.com/django/django/blob/main/django/db/backends/utils.py#L145-L150

Fixes google#287

CursorDebugWrapper already adds an entry to the queries_log post-execution: https://github.com/django/django/blob/main/django/db/backends/utils.py#L145-L150
# * https://github.com/basecamp/marginalia/pull/80

# Add the query to the query log if debugging.
if isinstance(context['cursor'], CursorDebugWrapper):
Copy link
Author

@artamonovkirill artamonovkirill Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd prefer explicit control over the log entry, we could update it instead:

  if isinstance(context['cursor'], CursorDebugWrapper):
      context['connection'].queries_log[-1]['sql'] = sql

This shouldn't be necessary anyway—since we modify the SQL before calling execute(), Django's logging already captures the commented version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Django integration breaks assertNumQueries

1 participant

Comments

Close sidebar
Morty Proxy This is a proxified and sanitized view of the page, visit original site.