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

This commit is contained in:
Dan Stillman 2010-07-13 19:00:58 +00:00
parent 0b83c8c166
commit ccae2e0b7c

View File

@ -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) {