Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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