comparison roundup/backends/rdbms_common.py @ 2318:fa2f7ba34399

merge from maint-0-7
author Richard Jones <richard@users.sourceforge.net>
date Sun, 16 May 2004 09:35:50 +0000
parents 3197e37346de
children 7cf7e3bd1b31
comparison
equal deleted inserted replaced
2316:f8a4c51e5847 2318:fa2f7ba34399
1 # $Id: rdbms_common.py,v 1.99 2004-05-10 01:30:02 richard Exp $ 1 # $Id: rdbms_common.py,v 1.100 2004-05-16 09:35:49 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
2121 else: 2121 else:
2122 where.append('_%s=%s'%(k, a)) 2122 where.append('_%s=%s'%(k, a))
2123 args.append(v) 2123 args.append(v)
2124 2124
2125 # don't match retired nodes 2125 # don't match retired nodes
2126 where.append('__retired__ <> 1') 2126 where.append('_%s.__retired__ <> 1'%cn)
2127 2127
2128 # add results of full text search 2128 # add results of full text search
2129 if search_matches is not None: 2129 if search_matches is not None:
2130 v = search_matches.keys() 2130 v = search_matches.keys()
2131 s = ','.join([a for x in v]) 2131 s = ','.join([a for x in v])
2144 continue 2144 continue
2145 elif isinstance(props[prop], Interval): 2145 elif isinstance(props[prop], Interval):
2146 # use the int column for sorting 2146 # use the int column for sorting
2147 o = '__'+prop+'_int__' 2147 o = '__'+prop+'_int__'
2148 ordercols.append(o) 2148 ordercols.append(o)
2149 elif isinstance(props[prop], Link):
2150 # determine whether the linked Class has an order property
2151 lcn = props[prop].classname
2152 link = self.db.classes[lcn]
2153 if link.getprops().has_key('order'):
2154 tn = '_' + lcn
2155 frum.append(tn)
2156 where.append('_%s._%s = %s.id'%(cn, prop, tn))
2157 ordercols.append(tn + '._order')
2158 o = tn + '._order'
2149 elif prop == 'id': 2159 elif prop == 'id':
2150 o = 'id' 2160 o = 'id'
2151 else: 2161 else:
2152 o = '_'+prop 2162 o = '_'+prop
2153 ordercols.append(o) 2163 ordercols.append(o)
2162 else: 2172 else:
2163 where = '' 2173 where = ''
2164 if mlfilt: 2174 if mlfilt:
2165 # we're joining tables on the id, so we will get dupes if we 2175 # we're joining tables on the id, so we will get dupes if we
2166 # don't distinct() 2176 # don't distinct()
2167 cols = ['distinct(id)'] 2177 cols = ['distinct(_%s.id)'%cn]
2168 else: 2178 else:
2169 cols = ['id'] 2179 cols = ['_%s.id'%cn]
2170 if orderby: 2180 if orderby:
2171 cols = cols + ordercols 2181 cols = cols + ordercols
2172 order = ' order by %s'%(','.join(orderby)) 2182 order = ' order by %s'%(','.join(orderby))
2173 else: 2183 else:
2174 order = '' 2184 order = ''

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