Detecte et supprime doublons dans les préférences

This commit is contained in:
Emmanuel Viennet 2021-10-25 15:49:56 +02:00
parent 66d443944a
commit 5268ea4f13
2 changed files with 10 additions and 3 deletions

View File

@ -1949,6 +1949,15 @@ class BasePreferences(object):
"name": name,
},
)
if len(pdb) > 1:
# suppress buggy duplicates (may come from corrupted database for ice ages)
log(
f"**oups** detected duplicated preference !\n({self.dept_id}, {formsemestre_id}, {name}, {value})"
)
for obj in pdb[1:]:
self._editor.delete(cnx, obj["id"])
pdb = [pdb[0]]
if not pdb:
# crée préférence
log("create pref sem=%s %s=%s" % (formsemestre_id, name, value))
@ -1962,10 +1971,8 @@ class BasePreferences(object):
},
)
modif = True
log("create pref sem=%s %s=%s" % (formsemestre_id, name, value))
else:
# edit existing value
existing_value = pdb[0]["value"] # old stored value
if (
(existing_value != value)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.0.55"
SCOVERSION = "9.0.56"
SCONAME = "ScoDoc"