mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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)"
|
cond = "c.id in (select id from cards order by mod desc limit 100)"
|
||||||
if neg:
|
if neg:
|
||||||
cond = "not (%s)" % cond
|
cond = "not (%s)" % cond
|
||||||
|
if cond:
|
||||||
self.lims['card'].append(cond)
|
self.lims['card'].append(cond)
|
||||||
|
else:
|
||||||
|
self.lims['valid'] = False
|
||||||
|
|
||||||
def _findText(self, val, neg, c):
|
def _findText(self, val, neg, c):
|
||||||
val = val.replace("*", "%")
|
val = val.replace("*", "%")
|
||||||
|
|
|
@ -110,6 +110,8 @@ def test_findCards():
|
||||||
assert len(deck.findCards("helloworld", full=True)) == 1
|
assert len(deck.findCards("helloworld", full=True)) == 1
|
||||||
assert len(deck.findCards("front:helloworld")) == 0
|
assert len(deck.findCards("front:helloworld")) == 0
|
||||||
assert len(deck.findCards("front:helloworld", full=True)) == 1
|
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():
|
def test_findReplace():
|
||||||
deck = getEmptyDeck()
|
deck = getEmptyDeck()
|
||||||
|
|
Loading…
Reference in a new issue