Re: [web2py] Re: Belongs with empty list fails on postgres

2013-04-12 Thread Richard Vézina
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 < ml.richard.vez...@gmail.com> wrote: > Hello, > > I fall on "(1=0)" with this query : > > There is these belongs : > > db(... & (db.tab

Re: [web2py] Re: Belongs with empty list fails on postgres

2013-04-12 Thread Richard Vézina
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 wrote: > I've been working around this Postgres/psycopg2 "feature" for ages. > > Something like this: > > que

[web2py] Re: Belongs with empty list fails on postgres

2012-11-08 Thread Cliff Kachinske
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

[web2py] Re: Belongs with empty list fails on postgres

2012-11-06 Thread Niphlod
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 = '

[web2py] Re: Belongs with empty list fails on postgres

2012-11-06 Thread Marin Pranjić
Done: 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. --

[web2py] Re: Belongs with empty list fails on postgres

2012-11-06 Thread Niphlod
ok then post a bug so it doesn't get lost. PS: I remember asking for the same thing and patching DAL, but it was for empty lists indeed. Il giorno martedì 6 novembre 2012 17:27:04 UTC+1, Marin Pranjić ha scritto: > > I tried this: > db(db.auth_user.id.belongs())._select(db.auth_user.id) > > And i

[web2py] Re: Belongs with empty list fails on postgres

2012-11-06 Thread Marin Pranjić
I tried this: db(db.auth_user.id.belongs())._select(db.auth_user.id) And it prints: 'SELECT auth_user.id FROM auth_user WHERE (1=0);' So, it works as expected. My question is invalid because I have something else in code: db.tablename.fieldname.belongs(set()) Which is not working: 'SELECT

[web2py] Re: Belongs with empty list fails on postgres

2012-11-06 Thread Niphlod
uhm. elif second==[] or second==(): return '(1=0)' why this is not reached ? what is printed when you use db(db.tablename.fieldname.belongs([]))._select() ? Il giorno martedì 6 novembre 2012 17:01:08 UTC+1, Marin Pranjić ha scritto: > > The issue is that SQLite allows to do: > someth