>> This: Model.objects.filter(...).exclude(id__in = processed)
>> gives me: Truncated incorrect DOUBLE value: 'Model object'
I've seen the above request on the ML several times now.
Is there any hope that, in the QuerySet refactor, the "__in" form
can sniff the datatype of the parameter for other querysets?
Thus, you could have something like
users = Users.objects.filter(...)
things = Foo.objects.filter(owner_id__in=users)
it seems that this would just translate to an IN/EXISTS query,
using the query definition from "users" to build the sub-query.
It's far more efficient to do that all on the server and just
return the correct results, rather than
things = Foo.objects.filter(owner_id__in=[
user.id for user in users])
which would force the entire set of users to be brought back and
translated into a list, and then ship off a potentially-long list
of IDs back in a 2nd query. (Imagine len(users) > REALLY_BIG_NUM)
The pseudo-code as I'd imagine it would be something like
if query_type = "in":
if issubclass(paramenter, QuerySet):
where_clause = 'IN (SELECT ID FROM %s WHERE %s)' % (
param.from_clause(), param.where_clause()
)
else:
where_clause = do_whatever_it_currently_does()
I haven't explored the QS refactor branch, but am looking forward
to its arrival so I can get started on tinkering with the
aggregate code.
-tkc
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---