From 2ba5f80cf14f37d85779131de167e70f413a471c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 7 Apr 2012 13:53:03 +0900 Subject: [PATCH] fix field searching and negated field searching --- anki/find.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/anki/find.py b/anki/find.py index 210d02a97..c601e4242 100644 --- a/anki/find.py +++ b/anki/find.py @@ -258,7 +258,7 @@ flds %s like :_text_%d escape '\\')""" % (extra, c, extra, c)) self.lims['valid'] = False return # gather nids - regex = value.replace("%", ".*") + regex = value.replace("_", ".").replace("%", ".*") nids = [] for (id,mid,flds) in self.col.db.execute(""" select id, mid, flds from notes @@ -273,7 +273,9 @@ where mid in %s and flds like ? escape '\\'""" % ( if re.search(regex, strg): nids.append(id) extra = "not" if isNeg else "" - self.lims['preds'].append("n.id %s in %s" % (extra, ids2str(nids))) + self.lims['preds'].append(""" +n.mid in %s and n.id %s in %s""" % ( + ids2str(mods.keys()), extra, ids2str(nids))) # Most of this function was written by Marcus def _parseQuery(self):