[Django] #23313: RawQuery.__repr__ fails when params passed as dict

13 views
Skip to first unread message

Django

unread,
Aug 18, 2014, 11:38:42 AM8/18/14
to django-...@googlegroups.com
#23313: RawQuery.__repr__ fails when params passed as dict
----------------------------------------------+-----------------------
Reporter: movEAX | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords: raw query
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+-----------------------
{{{
In [1]: from django.db.models.sql.query import RawQuery

In [2]: raw_query = RawQuery('SELECT %(foo)s', None, {'foo': 'bar'})

In [3]: repr(raw_query)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
<ipython-input-3-7fb02908cd64> in <module>()
----> 1 repr(raw_query)

/home/user/.src/django/django/db/models/sql/query.py in __repr__(self)
84
85 def __repr__(self):
---> 86 return "<RawQuery: %r>" % (self.sql % tuple(self.params))
87
88 def _execute_query(self):

TypeError: format requires a mapping
}}}

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

Django

unread,
Aug 18, 2014, 11:42:11 AM8/18/14
to django-...@googlegroups.com
#23313: RawQuery.__repr__ fails when params passed as dict
-------------------------------------+-------------------------------------

Reporter: movEAX | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: raw query | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

[https://github.com/django/django/pull/3078 Pull request #3078]

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

Django

unread,
Aug 18, 2014, 12:16:24 PM8/18/14
to django-...@googlegroups.com
#23313: RawQuery.__repr__ fails when params passed as dict
-------------------------------------+-------------------------------------

Reporter: movEAX | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: raw query | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Hi,

While `RawQuery` is an undocumented implementation detail, the issue you
found still seems worth fixing (plus I think it's possible to trigger it
using `Queryset.raw()` which **is** documented).

Thanks.

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

Django

unread,
Aug 29, 2014, 7:23:12 AM8/29/14
to django-...@googlegroups.com
#23313: RawQuery.__repr__ fails when params passed as dict
-------------------------------------+-------------------------------------
Reporter: movEAX | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: raw query | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"bc06d2c11c32bde94b717a75bd3325ef1b94c902"]:
{{{
#!CommitTicketReference repository=""
revision="bc06d2c11c32bde94b717a75bd3325ef1b94c902"
Fixed #23313 -- Corrected repr(RawQuery) with dict parameters.
}}}

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

Reply all
Reply to author
Forward
0 new messages