From 7ffff24790c4df995f908b4f18693bb625610361 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 10 Apr 2011 21:47:06 +0900 Subject: [PATCH] fix case where multiple models have the same template --- anki/find.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/anki/find.py b/anki/find.py index 661e16af0..f76ab95ab 100644 --- a/anki/find.py +++ b/anki/find.py @@ -164,6 +164,7 @@ order by %s""" % (lim, sort) num = int(val) - 1 except: num = None + lims = [] for m in self.deck.models().values(): for t in m.templates: # ordinal number? @@ -172,10 +173,12 @@ order by %s""" % (lim, sort) found = True # template name? elif t['name'].lower() == val.lower(): - self.lims['card'].append(( + lims.append(( "(fid in (select id from facts where mid = %d) " "and ord %s %d)") % (m.id, comp, t['ord'])) found = True + if lims: + self.lims['card'].append("(" + " or ".join(lims) + ")") self.lims['valid'] = found def _findField(self, token, isNeg):