Deal with SQLite db corrupted by None name mapping (#784)

Fixes #11011
This commit is contained in:
Paul Culley 2019-02-13 22:05:01 -06:00 committed by Sam Manzi
parent 39a0d8c648
commit 7a82b78ff9
2 changed files with 8 additions and 5 deletions

View File

@ -330,9 +330,11 @@ class DBAPI(DbGeneric):
"""
Return the defined names that have been assigned to a default grouping.
"""
self.dbapi.execute("SELECT name FROM name_group ORDER BY name")
self.dbapi.execute("SELECT name, grouping FROM name_group "
"ORDER BY name")
rows = self.dbapi.fetchall()
return [row[0] for row in rows]
# not None test below fixes db corrupted by 11011 for export
return [row[0] for row in rows if row[1] is not None]
def get_name_group_mapping(self, key):
"""
@ -341,7 +343,8 @@ class DBAPI(DbGeneric):
self.dbapi.execute(
"SELECT grouping FROM name_group WHERE name = ?", [key])
row = self.dbapi.fetchone()
if row:
if row and row[0] is not None:
# not None test fixes db corrupted by 11011
return row[0]
else:
return key
@ -566,7 +569,7 @@ class DBAPI(DbGeneric):
self.dbapi.execute("SELECT grouping FROM name_group WHERE name = ?",
[key])
row = self.dbapi.fetchone()
return True if row else False
return row and row[0] is not None
def set_name_group_mapping(self, name, grouping):
"""

View File

@ -1758,7 +1758,7 @@ class GrampsParser(UpdateCallback):
' with "%(parent)s", did not change this grouping to "%(value)s".') % {
'key' : key, 'parent' : present, 'value' : value }
self.user.warn(_("Gramps ignored a name grouping"), msg)
else:
elif value != 'None': # None test fixes file corrupted by 11011
self.db.set_name_group_mapping(key, value)
def start_last(self, attrs):