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

Comments

Close side panel

fixed django middleware: add query to debug log correctly#288

Open
florianschieder wants to merge 1 commit intogoogle:mastergoogle/sqlcommenter:masterfrom
puzzleYOU:fix-conn-queries-logpuzzleYOU/sqlcommenter:fix-conn-queries-logCopy head branch name to clipboard
Open

fixed django middleware: add query to debug log correctly#288
florianschieder wants to merge 1 commit intogoogle:mastergoogle/sqlcommenter:masterfrom
puzzleYOU:fix-conn-queries-logpuzzleYOU/sqlcommenter:fix-conn-queries-logCopy head branch name to clipboard

Conversation

@florianschieder
Copy link

This has likely never worked correctly, as Django's query log entry has ever since been a dictionary made of 'time' and 'sql'. I've locally mounted this sqlcommenter code state into a Django project of ours using assertNumQueries, and it worked, see output below. The queries are properly formatted into the connection debug log:

File "(...)/tests/test_dummy.py", line 7, in test_dummy
    with self.assertNumQueries(0):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/test/testcases.py", line 96, in __exit__
    self.test_case.assertEqual(
AssertionError: 2 != 0 : 2 queries executed, 0 expected
Captured queries were:
1. 
            SELECT [...]
            WHERE foo IN (1, 2, 3) /*controller='django_app.views.SomeView',framework='django%%3A5.0.11',route='SOME_SLUG'*/
[...]

Fixes #2.

This has likely never worked correctly, as Django's query log entry
has ever since been a dictionary made of 'time' and 'sql'.
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.

1 participant

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