|
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 $ |
2 | 2 | ''' Relational database (SQL) backend common code. |
3 | 3 |
|
4 | 4 | Basics: |
@@ -1781,20 +1781,21 @@ def filter(self, search_matches, filterspec, sort=(None,None), |
1781 | 1781 | where = [] |
1782 | 1782 | args = [] |
1783 | 1783 | a = self.db.arg |
| 1784 | + print filterspec |
1784 | 1785 | for k, v in filterspec.items(): |
1785 | 1786 | propclass = props[k] |
1786 | 1787 | # now do other where clause stuff |
1787 | 1788 | if isinstance(propclass, Multilink): |
1788 | 1789 | 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([])): |
1790 | 1795 | frum.append(tn) |
1791 | 1796 | s = ','.join([a for x in v]) |
1792 | 1797 | where.append('id=%s.nodeid and %s.linkid in (%s)'%(tn,tn,s)) |
1793 | 1798 | 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) |
1798 | 1799 | else: |
1799 | 1800 | frum.append(tn) |
1800 | 1801 | 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), |
1930 | 1931 | print >>hyperdb.DEBUG, 'filter', (self, sql, args) |
1931 | 1932 | self.db.cursor.execute(sql, args) |
1932 | 1933 | l = self.db.cursor.fetchall() |
| 1934 | + print sql, l |
1933 | 1935 |
|
1934 | 1936 | # return the IDs (the first column) |
1935 | 1937 | # XXX The filter(None, l) bit is sqlite-specific... if there's _NO_ |
|
0 commit comments