catch invalid grouping

This commit is contained in:
Damien Elmes 2012-05-26 13:00:01 +09:00
parent e80419fb53
commit d25e2453a6
2 changed files with 8 additions and 1 deletions

View file

@ -22,7 +22,11 @@ class Finder(object):
return []
order, rev = self._order(order)
sql = self._query(preds, order)
res = self.col.db.list(sql, *args)
try:
res = self.col.db.list(sql, *args)
except:
# invalid grouping
return []
if rev:
res.reverse()
return res

View file

@ -204,6 +204,9 @@ def test_findCards():
assert len(deck.findCards("-(tag:monkey OR tag:sheep)")) == 6
assert len(deck.findCards("tag:monkey or (tag:sheep sheep)")) == 2
assert len(deck.findCards("tag:monkey or (tag:sheep octopus)")) == 1
# invalid grouping shouldn't error
assert len(deck.findCards(")")) == 0
assert len(deck.findCards("(()")) == 0
def test_findReplace():
deck = getEmptyDeck()