mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
field operations should mod the schema immediately
This commit is contained in:
parent
49c0a5dd82
commit
a1693a3691
1 changed files with 5 additions and 1 deletions
|
@ -215,6 +215,9 @@ select id from cards where nid in (select id from notes where mid = ?)""",
|
||||||
self.save(m)
|
self.save(m)
|
||||||
|
|
||||||
def addField(self, m, field):
|
def addField(self, m, field):
|
||||||
|
# only mod schema if model isn't new
|
||||||
|
if m['id']:
|
||||||
|
self.col.modSchema()
|
||||||
m['flds'].append(field)
|
m['flds'].append(field)
|
||||||
self._updateFieldOrds(m)
|
self._updateFieldOrds(m)
|
||||||
self.save(m)
|
self.save(m)
|
||||||
|
@ -224,6 +227,7 @@ select id from cards where nid in (select id from notes where mid = ?)""",
|
||||||
self._transformFields(m, add)
|
self._transformFields(m, add)
|
||||||
|
|
||||||
def remField(self, m, field):
|
def remField(self, m, field):
|
||||||
|
self.col.modSchema()
|
||||||
idx = m['flds'].index(field)
|
idx = m['flds'].index(field)
|
||||||
m['flds'].remove(field)
|
m['flds'].remove(field)
|
||||||
self._updateFieldOrds(m)
|
self._updateFieldOrds(m)
|
||||||
|
@ -238,6 +242,7 @@ select id from cards where nid in (select id from notes where mid = ?)""",
|
||||||
self.renameField(m, field, None)
|
self.renameField(m, field, None)
|
||||||
|
|
||||||
def moveField(self, m, field, idx):
|
def moveField(self, m, field, idx):
|
||||||
|
self.col.modSchema()
|
||||||
oldidx = m['flds'].index(field)
|
oldidx = m['flds'].index(field)
|
||||||
if oldidx == idx:
|
if oldidx == idx:
|
||||||
return
|
return
|
||||||
|
@ -275,7 +280,6 @@ select id from cards where nid in (select id from notes where mid = ?)""",
|
||||||
# model hasn't been added yet?
|
# model hasn't been added yet?
|
||||||
if not m['id']:
|
if not m['id']:
|
||||||
return
|
return
|
||||||
self.col.modSchema()
|
|
||||||
r = []
|
r = []
|
||||||
for (id, flds) in self.col.db.execute(
|
for (id, flds) in self.col.db.execute(
|
||||||
"select id, flds from notes where mid = ?", m['id']):
|
"select id, flds from notes where mid = ?", m['id']):
|
||||||
|
|
Loading…
Reference in a new issue