Fix error removing >1000 items from a tag (due to compiled SQLite limit)
This commit is contained in:
parent
0b83c8c166
commit
ccae2e0b7c
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user