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 >> >> >> Is there a reason for >> elif second==[] or second==() >> >> while it could easily be >> elif not second >> ? >> >> This should fix it. >> > --