From: richard Date: Wed, 26 Mar 2003 05:28:32 +0000 (+0000) Subject: handle myriad of argument types to filter() X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5a59d241edbc71552748dd3fc7977a3f7d72322f;p=roundup.git handle myriad of argument types to filter() git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1628 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index b412443..278e83c 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.114 2003-03-26 04:56:21 richard Exp $ +#$Id: back_anydbm.py,v 1.115 2003-03-26 05:28:32 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -1640,7 +1640,7 @@ class Class(hyperdb.Class): l.append((LINK, k, u)) elif isinstance(propclass, Multilink): # the value -1 is a special "not set" sentinel - if v == '-1': + if v in ('-1', ['-1]): v = [] elif type(v) is not type([]): v = [v] diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index c627b62..77d02e7 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.49 2003-03-26 04:56:21 richard Exp $ +# $Id: rdbms_common.py,v 1.50 2003-03-26 05:28:32 richard Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -1781,20 +1781,21 @@ class Class(hyperdb.Class): where = [] args = [] a = self.db.arg + print filterspec for k, v in filterspec.items(): propclass = props[k] # now do other where clause stuff if isinstance(propclass, Multilink): tn = '%s_%s'%(cn, k) - if isinstance(v, type([])): + if v in ('-1', ['-1']): + # only match rows that have count(linkid)=0 in the + # corresponding multilink table) + where.append('id not in (select nodeid from %s)'%tn) + elif isinstance(v, type([])): frum.append(tn) s = ','.join([a for x in v]) where.append('id=%s.nodeid and %s.linkid in (%s)'%(tn,tn,s)) args = args + v - elif v == '-1': - # only match rows that have count(linkid)=0 in the - # corresponding multilink table) - where.append('id not in (select nodeid from %s)'%tn) else: frum.append(tn) where.append('id=%s.nodeid and %s.linkid=%s'%(tn, tn, a)) @@ -1930,6 +1931,7 @@ class Class(hyperdb.Class): print >>hyperdb.DEBUG, 'filter', (self, sql, args) self.db.cursor.execute(sql, args) l = self.db.cursor.fetchall() + print sql, l # return the IDs (the first column) # XXX The filter(None, l) bit is sqlite-specific... if there's _NO_