From 188a450d68c7c74f8e32234f655dec95d22eaf1c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 29 Mar 2007 13:51:54 +0000 Subject: [PATCH] Repair steps for note-saving bug --- chrome/content/zotero/xpcom/schema.js | 23 +++++++++++++++++++++++ userdata.sql | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 14bebe97a..83c88dffa 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -870,6 +870,29 @@ Zotero.Schema = new function(){ if (i==27) { Zotero.DB.query("UPDATE itemData SET fieldID=115 WHERE itemID IN (SELECT itemID FROM items WHERE itemTypeID=3) AND fieldID=12"); } + + if (i==28) { + var childNotes = Zotero.DB.query("SELECT * FROM itemNotes WHERE itemID IN (SELECT itemID FROM items) AND sourceItemID IS NOT NULL"); + for (var i=0; i maxLength) { + maxLength = reversed[j].itemID.length; + var maxLengthIndex = j; + } + } + if (maxLengthIndex) { + Zotero.DB.query("UPDATE itemNotes SET note=? WHERE itemID=?", [reversed[maxLengthIndex].itemID, childNotes[i].itemID]); + var f = function(text) { var t = text.substring(0, 80); var ln = t.indexOf("\n"); if (ln>-1 && ln<80) { t = t.substring(0, ln); } return t; } + Zotero.DB.query("UPDATE itemNoteTitles SET title=? WHERE itemID=?", [f(reversed[maxLengthIndex].itemID), childNotes[i].itemID]); + } + Zotero.DB.query("DELETE FROM itemNotes WHERE note=? AND sourceItemID=?", [childNotes[i].itemID, childNotes[i].sourceItemID]); + } + } } _updateSchema('userdata'); diff --git a/userdata.sql b/userdata.sql index 41efd9459..f63f4f42a 100644 --- a/userdata.sql +++ b/userdata.sql @@ -1,4 +1,4 @@ --- 27 +-- 28 -- This file creates tables containing user-specific data -- any changes -- to existing tables made here must be mirrored in transition steps in