mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 07:07:13 -05:00
catch invalid grouping
This commit is contained in:
parent
e80419fb53
commit
d25e2453a6
2 changed files with 8 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue