From 331e6d466835f047c3f8f3f7840d2361b27e01ff Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 3 May 2016 08:07:42 -0400 Subject: [PATCH] Database: add reload method; re-expand fields before reindexing --- gramps/gen/db/generic.py | 7 +++++++ gramps/plugins/database/dbapi.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index 5084e0923..89caa5710 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -739,6 +739,13 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): else: return super().get_table_func(table, func) + def reload(self): + """ + Reload, and recreate tables (if necessary). + Useful after db.drop_tables() + """ + self.load(self._directory) + def load(self, directory, callback=None, mode=None, force_schema_upgrade=False, force_bsddb_upgrade=False, diff --git a/gramps/plugins/database/dbapi.py b/gramps/plugins/database/dbapi.py index 76f7e3b03..9ca8fd879 100644 --- a/gramps/plugins/database/dbapi.py +++ b/gramps/plugins/database/dbapi.py @@ -1225,8 +1225,12 @@ class DBAPI(DbGeneric): callback(5) def rebuild_secondary(self, update): + # First, expand blob to individual fields: + self.rebuild_secondary_fields() + # Next, rebuild stats: gstats = self.get_gender_stats() self.genderStats = GenderStats(gstats) + # Rebuild all order_by fields: ## Rebuild place order_by: self.dbapi.execute("""select blob_data from place;""") row = self.dbapi.fetchone()