From a455a7253491af9d61502a3b6c36f4e76c0f00e0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 22 Sep 2017 01:22:33 -0400 Subject: [PATCH] Remove invalid relations mangled during import Not sure if this occurred for our own translators, but it addresses items created from #1282. --- chrome/content/zotero/xpcom/schema.js | 10 ++++++++++ resource/schema/userdata.sql | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index a3c90e8a70..7fda50779b 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -2469,6 +2469,16 @@ Zotero.Schema = new function(){ yield Zotero.DB.queryAsync("REPLACE INTO fileTypeMIMETypes VALUES(7, 'application/vnd.ms-powerpoint')"); } + else if (i == 97) { + let where = "WHERE predicate IN (" + Array.from(Array(20).keys()).map(i => `'${i}'`).join(', ') + ")"; + let rows = yield Zotero.DB.queryAsync("SELECT * FROM relationPredicates " + where); + for (let row of rows) { + yield Zotero.DB.columnQueryAsync("UPDATE items SET synced=0 WHERE itemID IN (SELECT itemID FROM itemRelations WHERE predicateID=?)", row.predicateID); + yield Zotero.DB.queryAsync("DELETE FROM itemRelations WHERE predicateID=?", row.predicateID); + } + yield Zotero.DB.queryAsync("DELETE FROM relationPredicates " + where); + } + // If breaking compatibility or doing anything dangerous, clear minorUpdateFrom } diff --git a/resource/schema/userdata.sql b/resource/schema/userdata.sql index 034fd9bd01..badb8fda89 100644 --- a/resource/schema/userdata.sql +++ b/resource/schema/userdata.sql @@ -1,4 +1,4 @@ --- 96 +-- 97 -- Copyright (c) 2009 Center for History and New Media -- George Mason University, Fairfax, Virginia, USA