[Django] #18631: A way to get handle to the generated query for terminal queryset methods

7 views
Skip to first unread message

Django

unread,
Jul 15, 2012, 6:00:39 PM7/15/12
to django-...@googlegroups.com
#18631: A way to get handle to the generated query for terminal queryset methods
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: New | Status: new
feature | Version: 1.4
Component: Database | Keywords:
layer (models, ORM) | Has patch: 0
Severity: Normal | Needs tests: 0
Triage Stage: | Easy pickings: 0
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
When debugging or testing generated ORM queries it is often useful to get
a handle to generated queryset from terminal qs methods (like .update() or
.aggregate()) instead of executing the query.

The attached proof-of-concept shows a way to achieve this.

--
Ticket URL: <https://code.djangoproject.com/ticket/18631>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 7, 2012, 5:08:58 PM9/7/12
to django-...@googlegroups.com
#18631: A way to get handle to the generated query for terminal queryset methods
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Design
Keywords: | decision needed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jwmayfield):

* cc: jason@… (added)
* stage: Unreviewed => Design decision needed


--
Ticket URL: <https://code.djangoproject.com/ticket/18631#comment:1>

Django

unread,
Sep 7, 2012, 5:09:21 PM9/7/12
to django-...@googlegroups.com
#18631: A way to get handle to the generated query for terminal queryset methods
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jwmayfield):

* cc: jason@… (removed)
* stage: Design decision needed => Unreviewed


--
Ticket URL: <https://code.djangoproject.com/ticket/18631#comment:2>

Django

unread,
Nov 5, 2012, 5:27:06 AM11/5/12
to django-...@googlegroups.com
#18631: A way to get handle to the generated query for terminal queryset methods
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):

* stage: Unreviewed => Accepted


Comment:

I am marking this as accepted.

I am not sure if the attached patch is the right way to do this. But some
way to do this would be nice for debugging purposes.

--
Ticket URL: <https://code.djangoproject.com/ticket/18631#comment:3>

Django

unread,
Aug 15, 2022, 10:41:13 PM8/15/22
to django-...@googlegroups.com
#18631: A way to get handle to the generated query for terminal queryset methods
-------------------------------------+-------------------------------------
Reporter: Anssi Kääriäinen | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: 1.4
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* status: new => closed
* resolution: => wontfix


Comment:

I'm not sure this worth keeping around.

Terminal operations such as `update` and `delete` can actually result in
multiple queries (MTI in the case of `update`, chain of `SELECT` and
`DELETE` in the case of `delete` where the `SELECT` must run to return the
actual data that would be passed to `DELETE`) and the cases where you want
to know the exact queries are better served through `django.db` logger
capture or using options such as `--debug-sql` when running tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/18631#comment:4>

Reply all
Reply to author
Forward
0 new messages