Opened 11 years ago
Closed 11 years ago
#23313 closed Bug (fixed)
RawQuery.__repr__ fails when params passed as dict
| Reported by: | movEAX | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | raw query |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
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.
comment:3 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Pull request #3078