gracefully handle invalid queries

This commit is contained in:
Damien Elmes 2011-04-29 11:46:26 +09:00
parent ddcf83bc7f
commit a65f241258
2 changed files with 6 additions and 1 deletions

View file

@ -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
if cond:
self.lims['card'].append(cond)
else:
self.lims['valid'] = False
def _findText(self, val, neg, c):
val = val.replace("*", "%")

View file

@ -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()