Re: [Django] #35388: `force_debug_cursor` does nothing in async

2024-04-18 Thread Django
#35388: `force_debug_cursor` does nothing in async
-+-
 Reporter:  James Ostrander  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  connection, db,  | Triage Stage:
  orm, force_debug_cursor|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by James Ostrander:

Old description:

> 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.
>

> **SYNC VIEW (WORKING):**
> {{{
> 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 VIEW (NOT WORKING):**
> {{{
> 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.

New description:

 Django version: 4.2.11
 Python version: 3.12

 Settings:

 {{{
 DEBUG=False
 LOGGING = {
 "version": 1,
 "disable_existing_loggers": False,
 "handlers": {
 "default": {
 "level": "DEBUG",
 "class": "logging.StreamHandler",
 },
 },
 "loggers": {
 "django.db.backends": {
 "handlers": ["default"],
 "level": "DEBUG",
 "propagate": False,
 },
 },
 }
 }}}

 For Pytest, where DEBUG=False, this removes a means of enabling query
 logging via override.


 **SYNC VIEW (WORKING):**
 {{{
 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 VIEW (NOT WORKING):**
 {{{
 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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ef21871b1-2eff41c3-0c3f-49f6-83f4-cf87e359f559-00%40eu-central-1.amazonses.com.


Re: [Django] #35388: `force_debug_cursor` does nothing in async

2024-04-18 Thread Django
#35388: `force_debug_cursor` does nothing in async
-+-
 Reporter:  James Ostrander  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  connection, db,  | Triage Stage:
  orm, force_debug_cursor|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by James Ostrander):

 If the fix is something simple, I would be happy to submit a PR.
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ef1fdc0b8-9a1a3395-6d63-4eb9-bbe0-6e759f3b773d-00%40eu-central-1.amazonses.com.


Re: [Django] #35388: `force_debug_cursor` does nothing in async

2024-04-18 Thread Django
#35388: `force_debug_cursor` does nothing in async
-+-
 Reporter:  James Ostrander  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  connection, db,  | Triage Stage:
  orm, force_debug_cursor|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by James Ostrander):

 * version:  5.0 => 4.2

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ef1c2a849-de7e5953-7467-4cc4-9a3e-bd51699574d1-00%40eu-central-1.amazonses.com.


Re: [Django] #35388: `force_debug_cursor` does nothing in async

2024-04-18 Thread Django
#35388: `force_debug_cursor` does nothing in async
-+-
 Reporter:  jlost|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  connection, db,  | Triage Stage:
  orm, force_debug_cursor|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by jlost:

Old description:

> 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.

New description:

 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.


 **SYNC VIEW (WORKING):**
 {{{
 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 VIEW (NOT WORKING):**
 {{{
 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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ef1c0b582-3162a507-8b4b-4470-89e0-1debecb85331-00%40eu-central-1.amazonses.com.


[Django] #35388: `force_debug_cursor` does nothing in async

2024-04-18 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ef1bf7c70-fd571cc0-42d2-4c7d-8b15-59939b2b2891-00%40eu-central-1.amazonses.com.