comparison roundup/backends/rdbms_common.py @ 2535:50da6d3bac46 maint-0.7

backport from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Sat, 03 Jul 2004 22:49:40 +0000
parents 7e823f8938e9
children 5455dd2ec6d7
comparison
equal deleted inserted replaced
2513:7e823f8938e9 2535:50da6d3bac46
1 # $Id: rdbms_common.py,v 1.98.2.14 2004-07-01 03:58:34 richard Exp $ 1 # $Id: rdbms_common.py,v 1.98.2.15 2004-07-03 22:49:40 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
1950 if None in values: 1950 if None in values:
1951 values.remove(None) 1951 values.remove(None)
1952 s = '_%s is NULL or '%prop 1952 s = '_%s is NULL or '%prop
1953 allvalues += tuple(values) 1953 allvalues += tuple(values)
1954 s += '_%s in (%s)'%(prop, ','.join([a]*len(values))) 1954 s += '_%s in (%s)'%(prop, ','.join([a]*len(values)))
1955 where.append(s) 1955 where.append('(' + s +')')
1956 tables = ['_%s'%self.classname] 1956 tables = ['_%s'%self.classname]
1957 if where: 1957 if where:
1958 o.append('(' + ' and '.join(where) + ')') 1958 o.append('(' + ' and '.join(where) + ')')
1959 1959
1960 # now multilinks 1960 # now multilinks
2123 # in a "substring" search. Note - need to quote the '%' so 2123 # in a "substring" search. Note - need to quote the '%' so
2124 # they make it through the python layer happily 2124 # they make it through the python layer happily
2125 v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v] 2125 v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v]
2126 2126
2127 # now add to the where clause 2127 # now add to the where clause
2128 where.append(' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s) 2128 where.append('('
2129 for s in v])) 2129 +' or '.join(["_%s._%s LIKE '%s'"%(cn, k, s) for s in v])
2130 +')')
2130 # note: args are embedded in the query string now 2131 # note: args are embedded in the query string now
2131 elif isinstance(propclass, Link): 2132 elif isinstance(propclass, Link):
2132 if isinstance(v, type([])): 2133 if isinstance(v, type([])):
2133 d = {} 2134 d = {}
2134 for entry in v: 2135 for entry in v:
2140 del d[None] 2141 del d[None]
2141 l.append('_%s._%s is NULL'%(cn, k)) 2142 l.append('_%s._%s is NULL'%(cn, k))
2142 if d: 2143 if d:
2143 v = d.keys() 2144 v = d.keys()
2144 s = ','.join([a for x in v]) 2145 s = ','.join([a for x in v])
2145 where.append('(_%s._%s in (%s))'%(cn, k, s)) 2146 l.append('(_%s._%s in (%s))'%(cn, k, s))
2146 args = args + v 2147 args = args + v
2147 where.append(' or '.join(l)) 2148 if l:
2149 where.append('(' + ' or '.join(l) +')')
2148 else: 2150 else:
2149 if v in ('-1', None): 2151 if v in ('-1', None):
2150 v = None 2152 v = None
2151 where.append('_%s._%s is NULL'%(cn, k)) 2153 where.append('_%s._%s is NULL'%(cn, k))
2152 else: 2154 else:

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