From e1349ec308580ec65eb5f24589fccdafe61b4a82 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 9 Mar 2010 06:07:45 +0000 Subject: [PATCH] Reindex search condition ids on search load in case they're not contiguous (fixes sync error) --- chrome/content/zotero/xpcom/search.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index 56a0613ee4..174780ae4f 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -208,6 +208,9 @@ Zotero.Search.prototype.load = function() { + "WHERE savedSearchID=? ORDER BY searchConditionID"; var conditions = Zotero.DB.query(sql, this._id); + // Reindex conditions, in case they're not contiguous in the DB + var conditionID = 1; + for (var i in conditions) { // Parse "condition[/mode]" var [condition, mode] = @@ -227,14 +230,16 @@ Zotero.Search.prototype.load = function() { conditions[i].value = Zotero.ItemTypes.getName(conditions[i].value); } - this._conditions[conditions[i]['searchConditionID']] = { - id: conditions[i]['searchConditionID'], + this._conditions[conditionID] = { + id: conditionID, condition: condition, mode: mode, operator: conditions[i]['operator'], value: conditions[i]['value'], required: conditions[i]['required'] }; + + conditionID++; } }