Skip to content

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