diff roundup/backends/rdbms_common.py @ 2508:8e1c1623710b

rdbms backends not filtering correctly on link=None
author Richard Jones <richard@users.sourceforge.net>
date Tue, 29 Jun 2004 05:51:38 +0000
parents bdd112cf61ba
children f5542d92307a
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Mon Jun 28 23:17:49 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Tue Jun 29 05:51:38 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.113 2004-06-28 23:13:05 richard Exp $
+# $Id: rdbms_common.py,v 1.114 2004-06-29 05:51:38 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -2133,20 +2133,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:

Roundup Issue Tracker: http://roundup-tracker.org/