Skip to content

Commit 3d78958

Browse files
author
Richard Jones
committed
fixes to anydbm filtering
1 parent 659ca65 commit 3d78958

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

roundup/backends/back_anydbm.py

Lines changed: 4 additions & 3 deletions
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: back_anydbm.py,v 1.143 2004-04-26 00:46:34 richard Exp $
18+
#$Id: back_anydbm.py,v 1.144 2004-05-04 00:16:06 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1776,11 +1776,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
17761776
def sortfun(a, b, directions=directions, n=range(len(directions))):
17771777
for i in n:
17781778
if a[i] == b[i]: continue
1779-
if directions[i] == '-':
1779+
if directions[i] == '+':
17801780
return cmp(a[i],b[i])
17811781
else:
17821782
return cmp(b[i],a[i])
1783-
return 0
1783+
# for consistency, sort by the id if the items are equal
1784+
return cmp(a[-2], b[-2])
17841785
matches.sort(sortfun)
17851786

17861787
# pull the id out of the individual entries

test/db_test_base.py

Lines changed: 4 additions & 4 deletions
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.25 2004-04-18 05:31:02 richard Exp $
18+
# $Id: db_test_base.py,v 1.26 2004-05-04 00:16:07 richard Exp $
1919

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

@@ -813,15 +813,15 @@ def filteringSetup(self):
813813
iss = self.db.issue
814814
for issue in (
815815
{'title': 'issue one', 'status': '2', 'assignedto': '1',
816-
'foo': date.Interval('1:10'),
816+
'foo': date.Interval('1:10'),
817817
'deadline': date.Date('2003-01-01.00:00')},
818818
{'title': 'issue two', 'status': '1', 'assignedto': '2',
819-
'foo': date.Interval('1d'),
819+
'foo': date.Interval('1d'),
820820
'deadline': date.Date('2003-02-16.22:50')},
821821
{'title': 'issue three', 'status': '1',
822822
'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')},
823823
{'title': 'non four', 'status': '3',
824-
'foo': date.Interval('0:10'),
824+
'foo': date.Interval('0:10'),
825825
'nosy': ['1'], 'deadline': date.Date('2004-03-08')}):
826826
self.db.issue.create(**issue)
827827
self.db.commit()

0 commit comments

Comments
 (0)