[Django] #25092: Inconsistency in Query.__str__ and actual query

5 views
Skip to first unread message

Django

unread,
Jul 9, 2015, 8:15:12 AM7/9/15
to django-...@googlegroups.com
#25092: Inconsistency in Query.__str__ and actual query
----------------------------------------------+--------------------
Reporter: coldmind | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Inspired by http://stackoverflow.com/a/31287932/2116126
Different backends may quote or do something with params, so actual query
diffs from the `Query.__str__`, which is inconsistent.
I think Django should format params how backend actually do this to
prevent confusion.

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

Django

unread,
Jul 9, 2015, 8:38:52 AM7/9/15
to django-...@googlegroups.com
#25092: Inconsistency in Query.__str__ and actual query
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

According to #17741, `str(query)` "isn't intended to give you valid SQL,
just a basic representation of the query." Therefore, not sure it's
feasible or practical to implement this.

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

Django

unread,
Jul 9, 2015, 8:43:23 AM7/9/15
to django-...@googlegroups.com
#25092: Inconsistency in Query.__str__ and actual query
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

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

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by coldmind):

Well, I can investigate if it is feasible.
The point about "a basic representation of the query" seems strange for
me. Why should we have a tool that differs from reality?
The practical thing is to have ability to get actual query without looking
to logs.

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

Django

unread,
Jul 9, 2015, 9:00:06 AM7/9/15
to django-...@googlegroups.com
#25092: Inconsistency in Query.__str__ and actual query
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

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

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

As the linked ticket says, "There isn't [a way to get the actual query],
because Django never actually interpolates the parameters: it sends the
query and the parameters separately to the database adapter, which
performs the appropriate operations."

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

Django

unread,
Jul 10, 2015, 2:26:31 PM7/10/15
to django-...@googlegroups.com
#25092: Inconsistency in Query.__str__ and actual query
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

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

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

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


Comment:

Feel free to reopen if you can come up with something more accurate than
the current situation.

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

Reply all
Reply to author
Forward
0 new messages