Hello,

the docs say:

"""
Passing parameters into raw()

If you need to perform parameterized queries, you can use the params
argument to raw():

>>> lname = 'Doe'
>>> Person.objects.raw('SELECT * FROM myapp_person WHERE last_name = %s', 
>>> [lname])

params is a list of parameters. You’ll use %s placeholders in the
query string (regardless of your database engine); they’ll be replaced
with parameters from the params list.
"""

howerver this woks just fine and I see no reason why this should not be done:

>>> param = dict(lname = 'Doe')
>>> qs = Person.objects.raw('SELECT * FROM myapp_person WHERE last_name = 
>>> %(lname)s', param)

however still this fails:

>>> repr(qs)
/home/user/vpy/dev/lib/python2.7/site-packages/django/db/models/query.pyc
in __repr__(self)
   1530
   1531     def __repr__(self):
-> 1532         return "<RawQuerySet: %r>" % (self.raw_query %
tuple(self.params))
   1533
   1534     def __getitem__(self, k):

TypeError: format requires a mapping

If no one objects, I could write a patch to the code and the docs that
implements the functionality.

Regards Roman

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to