Skip to content

Commit ffa2ab7

Browse files
committed
Fix find() with anydbm. Add fast return shortcut.
Using protected properties raised KeyError. Add shortcut fast return. Both changes come from rdbms_common.py's find(). Add test case.
1 parent 7449d6f commit ffa2ab7

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ Fixed:
122122
- issue2550964 - History can (temporarily) show incorrect value when a
123123
change is rejected. Fix history function to always use the database
124124
values and ignore the current setting in the form.
125+
- Fix find() with anydbm. Using protected properties raised KeyError.
126+
Add shortcut fast return. Both changes come from rdbms_common.py's
127+
find(). (John Rouillard)
125128

126129
Features:
127130
- issue2550522 - Add 'filter' command to command-line

roundup/backends/back_anydbm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,15 @@ def find(self, **propspec):
15061506
db.issue.find(messages=('1','3'), files=('7',))
15071507
db.issue.find(messages=['1','3'], files=['7'])
15081508
"""
1509+
# shortcut
1510+
if not propspec:
1511+
return []
1512+
1513+
# validate the args
1514+
props = self.getprops()
15091515
for propname, itemids in propspec.items():
15101516
# check the prop is OK
1511-
prop = self.properties[propname]
1517+
prop = props[propname]
15121518
if not isinstance(prop, hyperdb.Link) and not isinstance(prop, hyperdb.Multilink):
15131519
raise TypeError("'%s' not a Link/Multilink "
15141520
"property"%propname)
@@ -1537,7 +1543,7 @@ def find(self, **propspec):
15371543
continue
15381544

15391545
# grab the property definition and its value on this item
1540-
prop = self.properties[propname]
1546+
prop = props[propname]
15411547
value = item[propname]
15421548
if isinstance(prop, hyperdb.Link) and value in itemids:
15431549
l.append(id)

test/db_test_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,12 @@ def testFindLink(self):
15781578
got.sort()
15791579
self.assertEqual(got, [one, three])
15801580

1581+
def testFindProtectedLink(self):
1582+
one, two, three, four = self._find_test_setup()
1583+
got = self.db.issue.find(creator='1')
1584+
got.sort()
1585+
self.assertEqual(got, [one, two, three, four])
1586+
15811587
def testFindRevLinkMultilink(self):
15821588
ae, dummy = self.filteringSetupTransitiveSearch('user')
15831589
ni = 'nosy_issues'

0 commit comments

Comments
 (0)