Seems I can work around this like that :

db(... & (db.table.field.belongs(('item', ''))).select(...)

Richard


On Fri, Apr 12, 2013 at 12:39 PM, Richard Vézina <
[email protected]> wrote:

> Hello,
>
> I fall on "(1=0)" with this query :
>
> There is these belongs :
>
> db(... & (db.table.field.belongs(('item',))).select(...)
>
> Richard
>
>
> On Thu, Nov 8, 2012 at 12:29 PM, Cliff Kachinske <[email protected]> wrote:
>
>> I've been working around this Postgres/psycopg2 "feature" for ages.
>>
>> Something like this:
>>
>> query = db.sometable.somefield==somevalue
>> avoid = [id1, id2, id3] #could be an empty list
>> if len(avoid):
>>     query &= ~(db.sometable.id.belongs(avoid))
>>
>>
>> On Tuesday, November 6, 2012 12:06:22 PM UTC-5, Niphlod wrote:
>>>
>>> really don't know (but probably to ckeck for nulls)
>>>
>>> the complete code is
>>>
>>> def BELONGS(self, first, second):
>>>         if isinstance(second, str):
>>>             return '(%s IN (%s))' % (self.expand(first), second[:-1])
>>>         elif second==[] or second==():
>>>             return '(1=0)'
>>>         items = ','.join(self.expand(item, first.type) for item in
>>> second)
>>>         return '(%s IN (%s))' % (self.expand(first), items)
>>>
>>>
>>>
>>> Il giorno martedì 6 novembre 2012 18:01:59 UTC+1, Marin Pranjić ha
>>> scritto:
>>>>
>>>> Done: 
>>>> http://code.google.com/p/**web2py/issues/detail?id=1147<http://code.google.com/p/web2py/issues/detail?id=1147>
>>>>
>>>>
>>>> Is there a reason for
>>>> elif second==[] or second==()
>>>>
>>>> while it could easily be
>>>> elif not second
>>>> ?
>>>>
>>>> This should fix it.
>>>>
>>>  --
>>
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to