Opened 13 years ago
Closed 3 years ago
#18631 closed New feature (wontfix)
A way to get handle to the generated query for terminal queryset methods
| Reported by: | Anssi Kääriäinen | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.4 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (5)
by , 13 years ago
| Attachment: | ticket_18631_poc.diff added |
|---|
comment:1 by , 13 years ago
| Cc: | added |
|---|---|
| Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 13 years ago
| Cc: | removed |
|---|---|
| Triage Stage: | Design decision needed → Unreviewed |
comment:3 by , 13 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 3 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
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.
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.