Mercurial > p > roundup > code
changeset 2509:ea887c804103 maint-0.7
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 29 Jun 2004 05:53:37 +0000 |
| parents | f89a84f881f0 |
| children | 7e823f8938e9 |
| files | CHANGES.txt roundup/backends/back_mysql.py roundup/backends/rdbms_common.py test/db_test_base.py |
| diffstat | 4 files changed, 34 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Mon Jun 28 23:15:39 2004 +0000 +++ b/CHANGES.txt Tue Jun 29 05:53:37 2004 +0000 @@ -4,6 +4,7 @@ 2004-??-?? 0.7.6 Fixed: - rdbms backend full text search failure after import (sf bug 980314) +- rdbms backends not filtering correctly on link=None 2004-06-24 0.7.5
--- a/roundup/backends/back_mysql.py Mon Jun 28 23:15:39 2004 +0000 +++ b/roundup/backends/back_mysql.py Tue Jun 29 05:53:37 2004 +0000 @@ -607,20 +607,23 @@ # note: args are embedded in the query string now elif isinstance(propclass, Link): if isinstance(v, type([])): - if '-1' in v: - v = v[:] - v.remove('-1') - xtra = ' or _%s._%s is NULL'%(cn, k) - else: - xtra = '' - if v: + d = {} + for entry in v: + if entry == '-1': + entry = None + d[entry] = entry + l = [] + if d.has_key(None) or not d: + del d[None] + l.append('_%s._%s is NULL'%(cn, k)) + if d: + v = d.keys() s = ','.join([a for x in v]) - where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra)) + where.append('(_%s._%s in (%s))'%(cn, k, s)) args = args + v - else: - where.append('_%s._%s is NULL'%(cn, k)) + where.append(' or '.join(l)) else: - if v == '-1': + if v in ('-1', None): v = None where.append('_%s._%s is NULL'%(cn, k)) else:
--- a/roundup/backends/rdbms_common.py Mon Jun 28 23:15:39 2004 +0000 +++ b/roundup/backends/rdbms_common.py Tue Jun 29 05:53:37 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.98.2.12 2004-06-28 23:15:39 richard Exp $ +# $Id: rdbms_common.py,v 1.98.2.13 2004-06-29 05:53:37 richard Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -2130,20 +2130,23 @@ # note: args are embedded in the query string now elif isinstance(propclass, Link): if isinstance(v, type([])): - if '-1' in v: - v = v[:] - v.remove('-1') - xtra = ' or _%s._%s is NULL'%(cn, k) - else: - xtra = '' - if v: + d = {} + for entry in v: + if entry == '-1': + entry = None + d[entry] = entry + l = [] + if d.has_key(None) or not d: + del d[None] + l.append('_%s._%s is NULL'%(cn, k)) + if d: + v = d.keys() s = ','.join([a for x in v]) - where.append('(_%s._%s in (%s)%s)'%(cn, k, s, xtra)) + where.append('(_%s._%s in (%s))'%(cn, k, s)) args = args + v - else: - where.append('_%s._%s is NULL'%(cn, k)) + where.append(' or '.join(l)) else: - if v == '-1': + if v in ('-1', None): v = None where.append('_%s._%s is NULL'%(cn, k)) else:
--- a/test/db_test_base.py Mon Jun 28 23:15:39 2004 +0000 +++ b/test/db_test_base.py Tue Jun 29 05:53:37 2004 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: db_test_base.py,v 1.27.2.7 2004-06-24 07:14:49 richard Exp $ +# $Id: db_test_base.py,v 1.27.2.8 2004-06-29 05:53:37 richard Exp $ import unittest, os, shutil, errno, imp, sys, time, pprint @@ -877,6 +877,9 @@ ae, filt = self.filteringSetup() ae(filt(None, {'status': '1'}, ('+','id'), (None,None)), ['2','3']) ae(filt(None, {'assignedto': '-1'}, ('+','id'), (None,None)), ['3','4']) + ae(filt(None, {'assignedto': None}, ('+','id'), (None,None)), ['3','4']) + ae(filt(None, {'assignedto': ['-1', None]}, ('+','id'), (None,None)), + ['3','4']) def testFilteringRetired(self): ae, filt = self.filteringSetup()
