diff roundup/backends/rdbms_common.py @ 2317:4fd7a1805544 maint-0.7

fix anydbm sort/group direction handling... ...and make RDBMS sort/group use Link'ed "order" properties [SF#953148]
author Richard Jones <richard@users.sourceforge.net>
date Sun, 16 May 2004 09:33:14 +0000
parents 86bb9c804b41
children c075edcc8153
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Sat May 15 09:40:05 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Sun May 16 09:33:14 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.98.2.1 2004-05-10 01:27:59 richard Exp $
+# $Id: rdbms_common.py,v 1.98.2.2 2004-05-16 09:33:13 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -2123,7 +2123,7 @@
                     args.append(v)
 
         # don't match retired nodes
-        where.append('__retired__ <> 1')
+        where.append('_%s.__retired__ <> 1'%cn)
 
         # add results of full text search
         if search_matches is not None:
@@ -2146,6 +2146,16 @@
                     # use the int column for sorting
                     o = '__'+prop+'_int__'
                     ordercols.append(o)
+                elif isinstance(props[prop], Link):
+                    # determine whether the linked Class has an order property
+                    lcn = props[prop].classname
+                    link = self.db.classes[lcn]
+                    if link.getprops().has_key('order'):
+                        tn = '_' + lcn
+                        frum.append(tn)
+                        where.append('_%s._%s = %s.id'%(cn, prop, tn))
+                        ordercols.append(tn + '._order')
+                        o = tn + '._order'
                 elif prop == 'id':
                     o = 'id'
                 else:
@@ -2164,9 +2174,9 @@
         if mlfilt:
             # we're joining tables on the id, so we will get dupes if we
             # don't distinct()
-            cols = ['distinct(id)']
+            cols = ['distinct(_%s.id)'%cn]
         else:
-            cols = ['id']
+            cols = ['_%s.id'%cn]
         if orderby:
             cols = cols + ordercols
             order = ' order by %s'%(','.join(orderby))

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