Skip to content

Commit 90639d7

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent ab9c395 commit 90639d7

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ are given with the most recent entry first.
44
2004-??-?? 0.7.6
55
Fixed:
66
- rdbms backend full text search failure after import (sf bug 980314)
7+
- rdbms backends not filtering correctly on link=None
78

89

910
2004-06-24 0.7.5

roundup/backends/back_mysql.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -607,20 +607,23 @@ def filter(self, search_matches, filterspec, sort=(None,None),
607607
# note: args are embedded in the query string now
608608
elif isinstance(propclass, Link):
609609
if isinstance(v, type([])):
610-
if '-1' in v:
611-
v = v[:]
612-
v.remove('-1')
613-
xtra = ' or _%s._%s is NULL'%(cn, k)
614-
else:
615-
xtra = ''
616-
if v:
610+
d = {}
611+
for entry in v:
612+
if entry == '-1':
613+
entry = None
614+
d[entry] = entry
615+
l = []
616+
if d.has_key(None) or not d:
617+
del d[None]
618+
l.append('_%s._%s is NULL'%(cn, k))
619+
if d:
620+
v = d.keys()
617621
s = ','.join([a for x in v])
618-
where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra))
622+
where.append('(_%s._%s in (%s))'%(cn, k, s))
619623
args = args + v
620-
else:
621-
where.append('_%s._%s is NULL'%(cn, k))
624+
where.append(' or '.join(l))
622625
else:
623-
if v == '-1':
626+
if v in ('-1', None):
624627
v = None
625628
where.append('_%s._%s is NULL'%(cn, k))
626629
else:

roundup/backends/rdbms_common.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.98.2.12 2004-06-28 23:15:39 richard Exp $
1+
# $Id: rdbms_common.py,v 1.98.2.13 2004-06-29 05:53:37 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2130,20 +2130,23 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21302130
# note: args are embedded in the query string now
21312131
elif isinstance(propclass, Link):
21322132
if isinstance(v, type([])):
2133-
if '-1' in v:
2134-
v = v[:]
2135-
v.remove('-1')
2136-
xtra = ' or _%s._%s is NULL'%(cn, k)
2137-
else:
2138-
xtra = ''
2139-
if v:
2133+
d = {}
2134+
for entry in v:
2135+
if entry == '-1':
2136+
entry = None
2137+
d[entry] = entry
2138+
l = []
2139+
if d.has_key(None) or not d:
2140+
del d[None]
2141+
l.append('_%s._%s is NULL'%(cn, k))
2142+
if d:
2143+
v = d.keys()
21402144
s = ','.join([a for x in v])
2141-
where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra))
2145+
where.append('(_%s._%s in (%s))'%(cn, k, s))
21422146
args = args + v
2143-
else:
2144-
where.append('_%s._%s is NULL'%(cn, k))
2147+
where.append(' or '.join(l))
21452148
else:
2146-
if v == '-1':
2149+
if v in ('-1', None):
21472150
v = None
21482151
where.append('_%s._%s is NULL'%(cn, k))
21492152
else:

test/db_test_base.py

Lines changed: 4 additions & 1 deletion
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: db_test_base.py,v 1.27.2.7 2004-06-24 07:14:49 richard Exp $
18+
# $Id: db_test_base.py,v 1.27.2.8 2004-06-29 05:53:37 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -877,6 +877,9 @@ def testFilteringLink(self):
877877
ae, filt = self.filteringSetup()
878878
ae(filt(None, {'status': '1'}, ('+','id'), (None,None)), ['2','3'])
879879
ae(filt(None, {'assignedto': '-1'}, ('+','id'), (None,None)), ['3','4'])
880+
ae(filt(None, {'assignedto': None}, ('+','id'), (None,None)), ['3','4'])
881+
ae(filt(None, {'assignedto': ['-1', None]}, ('+','id'), (None,None)),
882+
['3','4'])
880883

881884
def testFilteringRetired(self):
882885
ae, filt = self.filteringSetup()

0 commit comments

Comments
 (0)