mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
catch cards without template in db check
This commit is contained in:
parent
7747bdca28
commit
bee3422a72
1 changed files with 13 additions and 0 deletions
|
@ -640,6 +640,19 @@ select id from notes where mid not in """ + ids2str(self.models.ids()))
|
||||||
"Deleted %d notes with missing note type.", len(ids))
|
"Deleted %d notes with missing note type.", len(ids))
|
||||||
% len(ids))
|
% len(ids))
|
||||||
self.remNotes(ids)
|
self.remNotes(ids)
|
||||||
|
# cards with invalid ordinal
|
||||||
|
for m in self.models.all():
|
||||||
|
ids = self.db.list("""
|
||||||
|
select id from cards where ord not in %s and nid in (
|
||||||
|
select id from notes where mid = ?)""" %
|
||||||
|
ids2str([t['ord'] for t in m['tmpls']]),
|
||||||
|
m['id'])
|
||||||
|
if ids:
|
||||||
|
problems.append(
|
||||||
|
ngettext("Deleted %d card with missing template.",
|
||||||
|
"Deleted %d cards with missing template.",
|
||||||
|
len(ids)) % len(ids))
|
||||||
|
self.remCards(ids)
|
||||||
# delete any notes with missing cards
|
# delete any notes with missing cards
|
||||||
ids = self.db.list("""
|
ids = self.db.list("""
|
||||||
select id from notes where id not in (select distinct nid from cards)""")
|
select id from notes where id not in (select distinct nid from cards)""")
|
||||||
|
|
Loading…
Reference in a new issue