Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.py @ 6427:f08907bfd5a1
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 03 Jun 2021 21:48:28 -0400 |
| parents | a0c0ee3ed8b1 |
| children | 30358e334232 408fd477761f |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Thu May 27 16:40:10 2021 -0400 +++ b/roundup/backends/back_anydbm.py Thu Jun 03 21:48:28 2021 -0400 @@ -1506,9 +1506,15 @@ db.issue.find(messages=('1','3'), files=('7',)) db.issue.find(messages=['1','3'], files=['7']) """ + # shortcut + if not propspec: + return [] + + # validate the args + props = self.getprops() for propname, itemids in propspec.items(): # check the prop is OK - prop = self.properties[propname] + prop = props[propname] if not isinstance(prop, hyperdb.Link) and not isinstance(prop, hyperdb.Multilink): raise TypeError("'%s' not a Link/Multilink " "property"%propname) @@ -1537,7 +1543,7 @@ continue # grab the property definition and its value on this item - prop = self.properties[propname] + prop = props[propname] value = item[propname] if isinstance(prop, hyperdb.Link) and value in itemids: l.append(id)
