Opened 7 years ago

Closed 7 years ago

#25092 closed Cleanup/optimization (wontfix)

Inconsistency in Query.__str__ and actual query

Reported by: Andriy Sokolovskiy Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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

Change History (4)

comment:1 Changed 7 years ago by Tim Graham

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.

comment:2 Changed 7 years ago by Andriy Sokolovskiy

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.

comment:3 Changed 7 years ago by Tim Graham

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

comment:4 Changed 7 years ago by Claude Paroz

Resolution: wontfix
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top