Thanks for letting me know. I was afraid I was missing something obvious.
On Oct 4, 5:48 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2007-10-03 at 22:44 +0000, tzeskimo wrote: > > I'm trying to write a custom QuerySet, but I'm a bit confused about > > how to properly use the method extra(). From my understanding, > > extra() accepts both "select" and "where" arguments, both of which can > > contain bind variables. You then pass the appropriate bind variable > > values to the "param" argument. > > > This method seems like it will fall apart if two QuerySets are chained > > together, both of which pass "select" and "where" arguments to extra. > > For example, wouldn't the following cause an issue: > > > class FooQuerySet: > > > def query1(self): > > > self.extra(select = {'something': "item * %s"}, where = "item > > < %s", params = (3, 5)) > > > def query2(self): > > > self.extra(select = {'something_else': "item / %s"}, where = > > "item > %s", params = (3, 5)) > > > model.custom_manager.all().query1().query2() > > The "select" portion of extra() was never really intended to support > parameters. There are bigger problems than the one you've noticed here: > since "select" is a dictionary, it's ordering is indeterminate and so > when you have multiple items in the dictionary, there is no way to > reliably map the parameters to those items. > > I've been toying with a couple of ideas in the context of the > queryset-refactor branch to possibly try and make this work (with a > little more effort on the side of the programmer), but it's never going > to be particularly neat and tidy. > > For now, you can't do that. It's unsupported. You will need to write > custom SQL. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---