comparison roundup/backends/rdbms_common.py @ 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
comparison
equal deleted inserted replaced
2506:f89a84f881f0 2509:ea887c804103
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 $
2 ''' Relational database (SQL) backend common code. 2 ''' Relational database (SQL) backend common code.
3 3
4 Basics: 4 Basics:
5 5
6 - map roundup classes to relational tables 6 - map roundup classes to relational tables
2128 where.append(' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s) 2128 where.append(' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s)
2129 for s in v])) 2129 for s in v]))
2130 # note: args are embedded in the query string now 2130 # note: args are embedded in the query string now
2131 elif isinstance(propclass, Link): 2131 elif isinstance(propclass, Link):
2132 if isinstance(v, type([])): 2132 if isinstance(v, type([])):
2133 if '-1' in v: 2133 d = {}
2134 v = v[:] 2134 for entry in v:
2135 v.remove('-1') 2135 if entry == '-1':
2136 xtra = ' or _%s._%s is NULL'%(cn, k) 2136 entry = None
2137 else: 2137 d[entry] = entry
2138 xtra = '' 2138 l = []
2139 if v: 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()
2140 s = ','.join([a for x in v]) 2144 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))
2142 args = args + v 2146 args = args + v
2143 else: 2147 where.append(' or '.join(l))
2144 where.append('_%s._%s is NULL'%(cn, k))
2145 else: 2148 else:
2146 if v == '-1': 2149 if v in ('-1', None):
2147 v = None 2150 v = None
2148 where.append('_%s._%s is NULL'%(cn, k)) 2151 where.append('_%s._%s is NULL'%(cn, k))
2149 else: 2152 else:
2150 where.append('_%s._%s=%s'%(cn, k, a)) 2153 where.append('_%s._%s=%s'%(cn, k, a))
2151 args.append(v) 2154 args.append(v)

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