[Django] #25416: Queries are displayed without values quoted

12 views
Skip to first unread message

Django

unread,
Sep 16, 2015, 9:32:33 AM9/16/15
to django-...@googlegroups.com
#25416: Queries are displayed without values quoted
----------------------------------------------+--------------------
Reporter: beruic | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
I am debugging some queries, and noticed an error in how my queries are
printed.
What I did in my code, was:

{{{
query_set = ModelClass.objects.filter([other_filters]).exclude(field='')
}}}

The `query_set.query` then contains somthing like:

{{{
SELECT [columns] FROM [table] WHERE [other_filters] AND NOT ([table].field
= ))
}}}

The QuerySet works, but note that there are no quotes around the empty
string value.

I tried with a value instead, which also does not get quoted. Even if it
contains spaces.
The issue is the same if I use `.filter()` instead of `.exclude()`.

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

Django

unread,
Sep 16, 2015, 3:18:38 PM9/16/15
to django-...@googlegroups.com
#25416: Queries are displayed without values quoted
-------------------------------------+-------------------------------------
Reporter: beruic | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: needsinfo
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 charettes):

* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi beruic,

The string representation of a `Query` is not meant to be valid SQL, it is
solely provided for introspection means.

Were you using this private API in order to generate SQL to execute your
query manually?

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

Django

unread,
Oct 5, 2015, 6:36:56 AM10/5/15
to django-...@googlegroups.com
#25416: Queries are displayed without values quoted
-------------------------------------+-------------------------------------
Reporter: beruic | Owner: nobody

Type: Uncategorized | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: invalid
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 beruic):

* resolution: needsinfo => invalid


Comment:

I don't know why my replies does not show here, so now I try a straight
comment instead:

I recon that I have misinterpreted the purpose of `query_set.query`, and
this ticket is thus invalid.

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

Reply all
Reply to author
Forward
0 new messages