mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
support limiting to single field in find and replace
This commit is contained in:
parent
cd44f3308b
commit
1f56bc3ec0
1 changed files with 7 additions and 3 deletions
10
anki/deck.py
10
anki/deck.py
|
@ -1634,15 +1634,19 @@ where id = :id""", pending)
|
||||||
# Find and replace
|
# Find and replace
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def findReplace(self, factIds, src, dst, isRe=False):
|
def findReplace(self, factIds, src, dst, isRe=False, field=None):
|
||||||
|
"Find and replace fields in a fact."
|
||||||
# find
|
# find
|
||||||
s = "select id, factId, value from fields where factId in %s"
|
s = "select id, factId, value from fields where factId in %s"
|
||||||
if isRe:
|
if isRe:
|
||||||
isRe = re.compile(src)
|
isRe = re.compile(src)
|
||||||
else:
|
else:
|
||||||
s += "and value like :v"
|
s += " and value like :v"
|
||||||
|
if field:
|
||||||
|
s += " and fieldModelId = :fmid"
|
||||||
rows = self.s.all(s % ids2str(factIds),
|
rows = self.s.all(s % ids2str(factIds),
|
||||||
v="%"+src.replace("%", "%%")+"%")
|
v="%"+src.replace("%", "%%")+"%",
|
||||||
|
fmid=field)
|
||||||
modded = []
|
modded = []
|
||||||
if isRe:
|
if isRe:
|
||||||
modded = [
|
modded = [
|
||||||
|
|
Loading…
Reference in a new issue