#25416 closed Uncategorized (invalid)
Queries are displayed without values quoted
| Reported by: | Jimmy Merrild Krag | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.8 |
| 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 |
Description
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().
Change History (2)
comment:1 by , 10 years ago
| Resolution: | → needsinfo |
|---|---|
| Status: | new → closed |
comment:2 by , 10 years ago
| Resolution: | needsinfo → invalid |
|---|
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.
Hi beruic,
The string representation of a
Queryis 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?