Skip to content

Commit bc56486

Browse files
author
Richard Jones
committed
handle myriad of argument types to filter()
1 parent 3dd1a62 commit bc56486

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.114 2003-03-26 04:56:21 richard Exp $
18+
#$Id: back_anydbm.py,v 1.115 2003-03-26 05:28:32 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -1640,7 +1640,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16401640
l.append((LINK, k, u))
16411641
elif isinstance(propclass, Multilink):
16421642
# the value -1 is a special "not set" sentinel
1643-
if v == '-1':
1643+
if v in ('-1', ['-1]):
16441644
v = []
16451645
elif type(v) is not type([]):
16461646
v = [v]

roundup/backends/rdbms_common.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.49 2003-03-26 04:56:21 richard Exp $
1+
# $Id: rdbms_common.py,v 1.50 2003-03-26 05:28:32 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1781,20 +1781,21 @@ def filter(self, search_matches, filterspec, sort=(None,None),
17811781
where = []
17821782
args = []
17831783
a = self.db.arg
1784+
print filterspec
17841785
for k, v in filterspec.items():
17851786
propclass = props[k]
17861787
# now do other where clause stuff
17871788
if isinstance(propclass, Multilink):
17881789
tn = '%s_%s'%(cn, k)
1789-
if isinstance(v, type([])):
1790+
if v in ('-1', ['-1']):
1791+
# only match rows that have count(linkid)=0 in the
1792+
# corresponding multilink table)
1793+
where.append('id not in (select nodeid from %s)'%tn)
1794+
elif isinstance(v, type([])):
17901795
frum.append(tn)
17911796
s = ','.join([a for x in v])
17921797
where.append('id=%s.nodeid and %s.linkid in (%s)'%(tn,tn,s))
17931798
args = args + v
1794-
elif v == '-1':
1795-
# only match rows that have count(linkid)=0 in the
1796-
# corresponding multilink table)
1797-
where.append('id not in (select nodeid from %s)'%tn)
17981799
else:
17991800
frum.append(tn)
18001801
where.append('id=%s.nodeid and %s.linkid=%s'%(tn, tn, a))
@@ -1930,6 +1931,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
19301931
print >>hyperdb.DEBUG, 'filter', (self, sql, args)
19311932
self.db.cursor.execute(sql, args)
19321933
l = self.db.cursor.fetchall()
1934+
print sql, l
19331935

19341936
# return the IDs (the first column)
19351937
# XXX The filter(None, l) bit is sqlite-specific... if there's _NO_

0 commit comments

Comments
 (0)