Skip to content

Commit f7d1603

Browse files
author
Richard Jones
committed
Fixed SQL generation for sort/group by separate Link properties [SF#1417565]
Metakit fails the new test. I have no idea why.
1 parent 9132479 commit f7d1603

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

CHANGES.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4-
2005-01-27 1.0
4+
2006-??-?? 1.0.1
5+
Fixed:
6+
- SQL generation for sort/group by separate Link properties (sf bug
7+
1417565)
8+
9+
2006-01-27 1.0
510
Feature:
611
- Lithuanian translation by Aiste Kesminaite
712
- Web User Interface language selection by form variable @language,

roundup/backends/back_mysql.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_mysql.py,v 1.65 2006-01-20 02:42:35 richard Exp $
1+
#$Id: back_mysql.py,v 1.66 2006-01-30 00:36:26 richard Exp $
22
#
33
# Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <[email protected]>
44
#
@@ -723,6 +723,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
723723
orderby = []
724724
ordercols = []
725725
mlsort = []
726+
rhsnum = 0
726727
for sortby in group, sort:
727728
sdir, prop = sortby
728729
if sdir and prop:
@@ -741,9 +742,11 @@ def filter(self, search_matches, filterspec, sort=(None,None),
741742
op = link.orderprop ()
742743
if op != 'id':
743744
tn = '_' + lcn
744-
loj.append('LEFT OUTER JOIN %s as rhs_ on %s=rhs_.id'
745-
%(tn, o))
746-
o = 'rhs_._%s'%op
745+
rhs = 'rhs%s_'%rhsnum
746+
rhsnum += 1
747+
loj.append('LEFT OUTER JOIN %s as %s on %s=%s.id'%(
748+
tn, rhs, o, rhs))
749+
o = '%s._%s'%(rhs, op)
747750
ordercols.append(o)
748751
elif prop == 'id':
749752
o = '_%s.id'%cn

roundup/backends/rdbms_common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.163 2006-01-24 08:27:54 a1s Exp $
1+
# $Id: rdbms_common.py,v 1.164 2006-01-30 00:36:26 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2158,6 +2158,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21582158
orderby = []
21592159
ordercols = []
21602160
mlsort = []
2161+
rhsnum = 0
21612162
for sortby in group, sort:
21622163
sdir, prop = sortby
21632164
if sdir and prop:
@@ -2176,9 +2177,11 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21762177
op = link.orderprop()
21772178
if op != 'id':
21782179
tn = '_' + lcn
2179-
loj.append('LEFT OUTER JOIN %s as rhs_ on %s=rhs_.id'
2180-
%(tn, o))
2181-
o = 'rhs_._%s'%op
2180+
rhs = 'rhs%s_'%rhsnum
2181+
rhsnum += 1
2182+
loj.append('LEFT OUTER JOIN %s as %s on %s=%s.id'%(
2183+
tn, rhs, o, rhs))
2184+
o = '%s._%s'%(rhs, op)
21822185
ordercols.append(o)
21832186
elif prop == 'id':
21842187
o = '_%s.id'%cn

test/db_test_base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.63 2006-01-23 05:24:33 richard Exp $
18+
# $Id: db_test_base.py,v 1.64 2006-01-30 00:36:26 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint, sets
2121

@@ -1021,6 +1021,15 @@ def testFilteringMultilinkSort(self):
10211021
ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3'])
10221022
ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2'])
10231023

1024+
def testFilteringLinkSortGroup(self):
1025+
# 1: status: 2, priority: 3
1026+
# 2: status: 1, priority: 3
1027+
# 3: status: 1, priority: 2,
1028+
# 4: status: 3, priority: 2,
1029+
ae, filt = self.filteringSetup()
1030+
ae(filt(None, {}, ('+','status'), ('+','priority')),
1031+
['1', '2', '4', '3'])
1032+
10241033
def testFilteringDateSort(self):
10251034
# '1': '2003-02-16.22:50'
10261035
# '2': '2003-01-01.00:00'

0 commit comments

Comments
 (0)