mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fix negation of normal searches
This commit is contained in:
parent
13cabe3983
commit
0faad28715
1 changed files with 8 additions and 7 deletions
15
anki/find.py
15
anki/find.py
|
@ -163,21 +163,22 @@ and c.nid=n.id %s""" % (q, order)
|
||||||
|
|
||||||
def _findText(self, val, neg, c):
|
def _findText(self, val, neg, c):
|
||||||
val = val.replace("*", "%")
|
val = val.replace("*", "%")
|
||||||
extra = "not" if neg else ""
|
|
||||||
if not self.full:
|
if not self.full:
|
||||||
self.lims['args']["_text_%d"%c] = "%"+val+"%"
|
self.lims['args']["_text_%d"%c] = "%"+val+"%"
|
||||||
self.lims['preds'].append("""\
|
txt = """
|
||||||
(sfld %s like :_text_%d escape '\\' or
|
(sfld like :_text_%d escape '\\' or flds like :_text_%d escape '\\')""" % (c,c)
|
||||||
flds %s like :_text_%d escape '\\')""" % (extra, c, extra, c))
|
if not neg:
|
||||||
|
self.lims['preds'].append(txt)
|
||||||
|
else:
|
||||||
|
self.lims['preds'].append("not " + txt)
|
||||||
else:
|
else:
|
||||||
# in the future we may want to apply this at the end to speed up
|
|
||||||
# the case where there are other limits
|
|
||||||
nids = []
|
nids = []
|
||||||
|
extra = "not" if neg else ""
|
||||||
for nid, flds in self.col.db.execute(
|
for nid, flds in self.col.db.execute(
|
||||||
"select id, flds from notes"):
|
"select id, flds from notes"):
|
||||||
if val in stripHTML(flds):
|
if val in stripHTML(flds):
|
||||||
nids.append(nid)
|
nids.append(nid)
|
||||||
self.lims['preds'].append("n.id in " + ids2str(nids))
|
self.lims['preds'].append("n.id %s in %s " % (extra, ids2str(nids)))
|
||||||
|
|
||||||
def _findNids(self, val):
|
def _findNids(self, val):
|
||||||
self.lims['preds'].append("n.id in (%s)" % val)
|
self.lims['preds'].append("n.id in (%s)" % val)
|
||||||
|
|
Loading…
Reference in a new issue