changeset 2380:1ccfcfeca61b maint-0.7

backport from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Sat, 29 May 2004 02:09:13 +0000
parents b48fcae8b2ad
children e94e261a1373
files CHANGES.txt roundup/backends/back_mysql.py roundup/backends/rdbms_common.py
diffstat 3 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Fri May 28 01:03:53 2004 +0000
+++ b/CHANGES.txt	Sat May 29 02:09:13 2004 +0000
@@ -5,6 +5,7 @@
 Fixed:
 - re-acquire the OTK manager when we re-open the database
 - mailgw handler can close the database on us
+- fixed grouping by a NULL Link value
 
 
 2004-05-28 0.7.3
--- a/roundup/backends/back_mysql.py	Fri May 28 01:03:53 2004 +0000
+++ b/roundup/backends/back_mysql.py	Sat May 29 02:09:13 2004 +0000
@@ -515,14 +515,17 @@
         cn = self.classname
 
         timezone = self.db.getUserTimezone()
-        
+
+        # vars to hold the components of the SQL statement
+        frum = ['_'+cn] # FROM clauses
+        loj = []        # LEFT OUTER JOIN clauses
+        where = []      # WHERE clauses
+        args = []       # *any* positional arguments
+        a = self.db.arg
+
         # figure the WHERE clause from the filterspec
         props = self.getprops()
-        frum = ['_'+cn]
-        where = []
-        args = []
-        a = self.db.arg
-        mlfilt = 0
+        mlfilt = 0      # are we joining with Multilink tables?
         for k, v in filterspec.items():
             propclass = props[k]
             # now do other where clause stuff
@@ -668,12 +671,15 @@
                     # determine whether the linked Class has an order property
                     lcn = props[prop].classname
                     link = self.db.classes[lcn]
+                    o = '_%s._%s'%(cn, prop)
                     if link.getprops().has_key('order'):
                         tn = '_' + lcn
-                        frum.append(tn)
-                        where.append('_%s._%s = %s.id'%(cn, prop, tn))
+                        loj.append('LEFT OUTER JOIN %s on %s=%s.id'%(tn,
+                            o, tn))
                         ordercols.append(tn + '._order')
                         o = tn + '._order'
+                    else:
+                        ordercols.append(o)
                 elif prop == 'id':
                     o = '_%s.id'%cn
                 else:
@@ -701,7 +707,8 @@
         else:
             order = ''
         cols = ','.join(cols)
-        sql = 'select %s from %s %s%s'%(cols, frum, where, order)
+        loj = ' '.join(loj)
+        sql = 'select %s from %s %s %s%s'%(cols, frum, loj, where, order)
         args = tuple(args)
         if __debug__:
             print >>hyperdb.DEBUG, 'filter', (self, sql, args)
--- a/roundup/backends/rdbms_common.py	Fri May 28 01:03:53 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Sat May 29 02:09:13 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.98.2.4 2004-05-23 23:26:29 richard Exp $
+# $Id: rdbms_common.py,v 1.98.2.5 2004-05-29 02:09:13 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -2007,13 +2007,16 @@
         cn = self.classname
 
         timezone = self.db.getUserTimezone()
-        
+
+        # vars to hold the components of the SQL statement
+        frum = ['_'+cn] # FROM clauses
+        loj = []        # LEFT OUTER JOIN clauses
+        where = []      # WHERE clauses
+        args = []       # *any* positional arguments
+        a = self.db.arg
+
         # figure the WHERE clause from the filterspec
         props = self.getprops()
-        frum = ['_'+cn]
-        where = []
-        args = []
-        a = self.db.arg
         mlfilt = 0      # are we joining with Multilink tables?
         for k, v in filterspec.items():
             propclass = props[k]
@@ -2154,12 +2157,15 @@
                     # determine whether the linked Class has an order property
                     lcn = props[prop].classname
                     link = self.db.classes[lcn]
+                    o = '_%s._%s'%(cn, prop)
                     if link.getprops().has_key('order'):
                         tn = '_' + lcn
-                        frum.append(tn)
-                        where.append('_%s._%s = %s.id'%(cn, prop, tn))
+                        loj.append('LEFT OUTER JOIN %s on %s=%s.id'%(tn,
+                            o, tn))
                         ordercols.append(tn + '._order')
                         o = tn + '._order'
+                    else:
+                        ordercols.append(o)
                 elif prop == 'id':
                     o = '_%s.id'%cn
                 else:
@@ -2187,7 +2193,8 @@
         else:
             order = ''
         cols = ','.join(cols)
-        sql = 'select %s from %s %s%s'%(cols, frum, where, order)
+        loj = ' '.join(loj)
+        sql = 'select %s from %s %s %s%s'%(cols, frum, loj, where, order)
         args = tuple(args)
         if __debug__:
             print >>hyperdb.DEBUG, 'filter', (self, sql, args)

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