From abcf304ea7c0afa638cb4d7a40d50b1b69bab410 Mon Sep 17 00:00:00 2001 From: Paul Culley Date: Mon, 21 Jan 2019 21:19:25 -0600 Subject: [PATCH] Fix Name editor crash after clearing a group_as name on dbapi dbs (#771) Fixes #10981 --- gramps/plugins/db/dbapi/dbapi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/db/dbapi/dbapi.py b/gramps/plugins/db/dbapi/dbapi.py index ca28a5391..5706fae7a 100644 --- a/gramps/plugins/db/dbapi/dbapi.py +++ b/gramps/plugins/db/dbapi/dbapi.py @@ -576,14 +576,18 @@ class DBAPI(DbGeneric): self.dbapi.execute("SELECT 1 FROM name_group WHERE name = ?", [name]) row = self.dbapi.fetchone() - if row: + if row and grouping is not None: self.dbapi.execute("UPDATE name_group SET grouping=? " "WHERE name = ?", [grouping, name]) + elif row and grouping is None: + self.dbapi.execute("DELETE FROM name_group WHERE name = ?", [name]) + grouping = '' else: self.dbapi.execute( "INSERT INTO name_group (name, grouping) VALUES (?, ?)", [name, grouping]) self._txn_commit() + self.emit('person-groupname-rebuild', (name, grouping)) def _commit_base(self, obj, obj_key, trans, change_time): """