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()


In this example, the two select statements will appear at the
beginning of the query, and therefore bind to the first two
parameters.  However, due to the order in which the bind parameters
are passed to extra(), the second bind parameter should actually
belong to the "where" statement of query1.  Is this simply an
unsupported method of using extra?  Is there a better alternative?
The only thing I can think of is to do the quoting myself, or write
the raw sql myself, in which case the query set can't be chained.
Both of these options seem less than idea.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to