www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit ccae2e0b7c4c804bc48b2b4f0ee16117e466bcb2
parent 0b83c8c166598911a9c8e2ba9460a940b1680ffb
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 13 Jul 2010 19:00:58 +0000

Fix error removing >1000 items from a tag (due to compiled SQLite limit)


Diffstat:
Mchrome/content/zotero/xpcom/data/tag.js | 20+++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/tag.js b/chrome/content/zotero/xpcom/data/tag.js @@ -394,11 +394,21 @@ Zotero.Tag.prototype.save = function (full) { } if (removed.length) { - var sql = "DELETE FROM itemTags WHERE tagID=? " - + "AND itemID IN (" - + removed.map(function () '?').join() - + ")"; - Zotero.DB.query(sql, [tagID].concat(removed)); + var done = 0; + var maxItems = 998; // stay below compiled limit + var numItems = removed.length; + var tempRemoved = removed; + + do { + var chunk = tempRemoved.splice(0, maxItems); + + var sql = "DELETE FROM itemTags WHERE tagID=? " + + "AND itemID IN (" + chunk.map(function () '?').join() + ")"; + Zotero.DB.query(sql, [tagID].concat(chunk)); + + done += chunk.length; + } + while (done < numItems); } if (newids.length) {