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) { if (removed.length) {
var sql = "DELETE FROM itemTags WHERE tagID=? " var done = 0;
+ "AND itemID IN (" var maxItems = 998; // stay below compiled limit
+ removed.map(function () '?').join() var numItems = removed.length;
+ ")"; var tempRemoved = removed;
Zotero.DB.query(sql, [tagID].concat(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) { if (newids.length) {