#35388: `force_debug_cursor` does nothing in async
-------------------------------------+-------------------------------------
Reporter: jlost | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) | Keywords: connection, db,
Severity: Normal | orm, force_debug_cursor
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django version: 4.2.11
Python version: 3.12
Settings:
{{{
DEBUG=False
}}}
For Pytest, where DEBUG=False, this removes a means of enabling query
logging via override.
{{{
def query_test_sync(request: HttpRequest) -> HttpResponse:
from django.db import connection
connection.force_debug_cursor = True
a = Thing.objects.first()
return HttpResponse(f"First thing: {a.id}")
}}}
Log:
{{{
web-1 | [18/Apr/2024 14:48:35] "GET /test_query_sync/ HTTP/1.1" 200
31
web-1 | (0.001) SELECT "thing_thing"."name", "thing_thing"."id" FROM
"thing_thing" ORDER BY "thing_thing"."id" ASC LIMIT 1; args=();
alias=default
}}}
{{{
async def query_test_async(request: HttpRequest) -> HttpResponse:
from django.db import connection
connection.force_debug_cursor = True
a = await Thing.objects.afirst()
return HttpResponse(f"First thing: {a.id}")
}}}
Log:
{{{
web-1 | [18/Apr/2024 15:00:29] "GET /test_query_async/ HTTP/1.1" 200
31
}}}
Also worth noting: CaptureQueriesContext does not work in an async
context.
--
Ticket URL: <https://code.djangoproject.com/ticket/35388>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018ef1bf7c70-fd571cc0-42d2-4c7d-8b15-59939b2b2891-000000%40eu-central-1.amazonses.com.