Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16111 closed Bug (invalid)

Invalid SQL string representation from some queries

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

Description

A query like this:

str(User.objects.filter(username='admin').query)

produces invalid sql like this (note the missing ' around 'admin'):

SELECT ... FROM "auth_user" WHERE "auth_user"."username" = admin

The query does produces correct results nonetheless, the problem is only in the string representation... but it's annoying for debugging queries.

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

.query is undocumented (and probably on its way to disappear) so I don't think a ticket about it is valid. A similar problem in was fixed in r16081 for django.deb.connection.queries post-1.3 and will be available in 1.4

See the notes that commit adds. If your DB backend is sqlite3 they might explain error in quoting you are seeing.

comment:2 Changed 3 years ago by Kronuz

  • Cc Kronuz added
  • UI/UX unset

Nope, my backend is PostgreSQL, the values are unescaped (by the stringification of the query)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.