Mercurial > p > roundup > code
comparison roundup/backends/rdbms_common.py @ 3693:a775afeeee8b
Database interface fixes.
- Fix a problem with wrong sort-order in RDBMS backend when a
sort-attribute is also searched for. We need to preserve correct sort
attribute order in that case. A test for this was added earlier.
- Added forgotten fail_ok parameter to sql_commit method in sqlite
backend to make tests work again.
- Note that this version still fails a test for the postgresql backend.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Wed, 30 Aug 2006 09:05:30 +0000 |
| parents | 722ab52d47fc |
| children | 595041d78104 |
comparison
equal
deleted
inserted
replaced
| 3692:8e52157e2073 | 3693:a775afeeee8b |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 #$Id: rdbms_common.py,v 1.179 2006-08-29 04:32:49 richard Exp $ | 18 #$Id: rdbms_common.py,v 1.180 2006-08-30 09:05:30 schlatterbeck Exp $ |
| 19 ''' Relational database (SQL) backend common code. | 19 ''' Relational database (SQL) backend common code. |
| 20 | 20 |
| 21 Basics: | 21 Basics: |
| 22 | 22 |
| 23 - map roundup classes to relational tables | 23 - map roundup classes to relational tables |
| 2090 p.tree_sort_done = False | 2090 p.tree_sort_done = False |
| 2091 p = p.parent | 2091 p = p.parent |
| 2092 if not mlseen: | 2092 if not mlseen: |
| 2093 pt.attr_sort_done = pt.tree_sort_done = True | 2093 pt.attr_sort_done = pt.tree_sort_done = True |
| 2094 proptree.compute_sort_done() | 2094 proptree.compute_sort_done() |
| 2095 | 2095 |
| 2096 orderby = [] | |
| 2097 ordercols = [] | 2096 ordercols = [] |
| 2098 auxcols = {} | 2097 auxcols = {} |
| 2099 mlsort = [] | 2098 mlsort = [] |
| 2100 rhsnum = 0 | 2099 rhsnum = 0 |
| 2101 for p in proptree: | 2100 for p in proptree: |
| 2260 desc = ['', ' desc'][p.sort_direction == '-'] | 2259 desc = ['', ' desc'][p.sort_direction == '-'] |
| 2261 # Some SQL dbs sort NULL values last -- we want them first. | 2260 # Some SQL dbs sort NULL values last -- we want them first. |
| 2262 if (self.order_by_null_values and p.name != 'id'): | 2261 if (self.order_by_null_values and p.name != 'id'): |
| 2263 nv = self.order_by_null_values % oc | 2262 nv = self.order_by_null_values % oc |
| 2264 ordercols.append(nv) | 2263 ordercols.append(nv) |
| 2265 orderby.append(nv + desc) | 2264 p.orderby.append(nv + desc) |
| 2266 orderby.append(oc + desc) | 2265 p.orderby.append(oc + desc) |
| 2267 | 2266 |
| 2268 props = self.getprops() | 2267 props = self.getprops() |
| 2269 | 2268 |
| 2270 # don't match retired nodes | 2269 # don't match retired nodes |
| 2271 where.append('_%s.__retired__ <> 1'%icn) | 2270 where.append('_%s.__retired__ <> 1'%icn) |
| 2288 # we're joining tables on the id, so we will get dupes if we | 2287 # we're joining tables on the id, so we will get dupes if we |
| 2289 # don't distinct() | 2288 # don't distinct() |
| 2290 cols = ['distinct(_%s.id)'%icn] | 2289 cols = ['distinct(_%s.id)'%icn] |
| 2291 else: | 2290 else: |
| 2292 cols = ['_%s.id'%icn] | 2291 cols = ['_%s.id'%icn] |
| 2293 if orderby: | 2292 if ordercols: |
| 2294 cols = cols + ordercols | 2293 cols = cols + ordercols |
| 2295 order = ' order by %s'%(','.join(orderby)) | 2294 order = [] |
| 2295 # keep correct sequence of order attributes. | |
| 2296 for sa in proptree.sortattr: | |
| 2297 if not sa.attr_sort_done: | |
| 2298 continue | |
| 2299 order.extend(sa.orderby) | |
| 2300 if order: | |
| 2301 order = ' order by %s'%(','.join(order)) | |
| 2296 else: | 2302 else: |
| 2297 order = '' | 2303 order = '' |
| 2298 for o, p in auxcols.iteritems (): | 2304 for o, p in auxcols.iteritems (): |
| 2299 cols.append (o) | 2305 cols.append (o) |
| 2300 p.auxcol = len (cols) - 1 | 2306 p.auxcol = len (cols) - 1 |
