mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
gracefully handle invalid queries
This commit is contained in:
parent
ddcf83bc7f
commit
a65f241258
2 changed files with 6 additions and 1 deletions
|
@ -157,7 +157,10 @@ order by %s""" % (lim, sort)
|
|||
cond = "c.id in (select id from cards order by mod desc limit 100)"
|
||||
if neg:
|
||||
cond = "not (%s)" % cond
|
||||
self.lims['card'].append(cond)
|
||||
if cond:
|
||||
self.lims['card'].append(cond)
|
||||
else:
|
||||
self.lims['valid'] = False
|
||||
|
||||
def _findText(self, val, neg, c):
|
||||
val = val.replace("*", "%")
|
||||
|
|
|
@ -110,6 +110,8 @@ def test_findCards():
|
|||
assert len(deck.findCards("helloworld", full=True)) == 1
|
||||
assert len(deck.findCards("front:helloworld")) == 0
|
||||
assert len(deck.findCards("front:helloworld", full=True)) == 1
|
||||
# searching for an invalid special tag should not error
|
||||
assert len(deck.findCards("is:invalid")) == 0
|
||||
|
||||
def test_findReplace():
|
||||
deck = getEmptyDeck()
|
||||
|
|
Loading…
Reference in a new issue