Skip to content

Commit b660a5c

Browse files
committed
Fix sort-representation for RDBMS backends
...when sorting on Multilinks in python This fixes issue2550834 "postgres gets error with Date attribute in groupby sort".
1 parent 9d75c28 commit b660a5c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,8 @@ def filter(self, search_matches, filterspec, sort=[], group=[]):
26752675
# Compute values needed for sorting in proptree.sort
26762676
for p in proptree:
26772677
if hasattr(p, 'auxcol'):
2678-
p.sort_ids = p.sort_result = [row[p.auxcol] for row in l]
2678+
p.sort_ids = [row[p.auxcol] for row in l]
2679+
p.sort_result = p._sort_repr (p.propclass.sort_repr, p.sort_ids)
26792680
# return the IDs (the first column)
26802681
# XXX numeric ids
26812682
l = [str(row[0]) for row in l]

test/db_test_base.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,27 @@ def testDateSort(self):
442442
ae(filt(None, {}, ('-','id'), ('-', 'deadline')),
443443
['4', '3', '1', '2', '5'])
444444

445+
def testDateSortMultilink(self):
446+
d1 = date.Date('.')
447+
ae, filter, filter_iter = self.filteringSetup()
448+
nid = self.db.issue.create(title="nodeadline", status='1')
449+
self.db.commit()
450+
ae(sorted(self.db.issue.get('1','nosy')), [])
451+
ae(sorted(self.db.issue.get('2','nosy')), [])
452+
ae(sorted(self.db.issue.get('3','nosy')), ['1','2'])
453+
ae(sorted(self.db.issue.get('4','nosy')), ['1','2','3'])
454+
ae(sorted(self.db.issue.get('5','nosy')), [])
455+
ae(self.db.user.get('1','username'), 'admin')
456+
ae(self.db.user.get('2','username'), 'fred')
457+
ae(self.db.user.get('3','username'), 'bleep')
458+
# filter_iter currently doesn't work for Multilink sort
459+
# so testing only filter
460+
ae(filter(None, {}, ('+', 'id'), ('+','nosy')),
461+
['1', '2', '5', '4', '3'])
462+
ae(filter(None, {}, ('+','deadline'), ('+', 'nosy')),
463+
['5', '2', '1', '4', '3'])
464+
ae(filter(None, {}, ('+','nosy'), ('+', 'deadline')),
465+
['5', '2', '1', '3', '4'])
445466

446467
# Interval
447468
def testIntervalChange(self):

0 commit comments

Comments
 (0)