On Apr 30, 2006, at 1:31 PM, Ivan Sagalaev wrote:

>
> Cheng Zhang wrote:
>
>> I tried lookup like Article.objects.filter(id__in = []), which will
>> have SQL statement whose where clause is something like 'WHERE
>> ("poll_article"."id" IN ())'. Such SQL statement is ok with SQLite
>> but invalid for PostgreSQL.
>>
>> I work around this problem with code like:
>> if len(id_list) > 0:
>>   Article.objects.filter(id__in = id_list)
>> else:
>>   Article.objects.filter(id__isnull = True)
>>
>> Should this problem be deal with on the Django framework level,
>> instead of application level?
>>
>>
> It shouldn't. Because in defferent situations people need different
> things when the list in the condition is empty. Empty list can mean
> "don't filter, get everything" or "equals to nothing so get empty  
> list".
> And with your workaround user can get some arbitrary set of records
> where the field value happens to be NULL.
>
> So this really should be handled manually.

To elaborate on the question, it should be asked as:
In terms of Django's db-api, what will be in the QuerySet of filter 
(id__in=[])?

I still think it should mean an empty QuerySet. If one want to  
express the meaning of an everything QuerySet, one should use all()  
instead of filter().

- Cheng


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to