Fix SQL error saving an item with hundreds of related items
Fixes #2139
This commit is contained in:
parent
14b7206276
commit
576b9b7817
1 changed files with 10 additions and 4 deletions
|
@ -1102,11 +1102,17 @@ Zotero.DataObject.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
|
|||
toAdd[i][0] = yield Zotero.RelationPredicates.add(toAdd[i][0]);
|
||||
env.relationsToRegister.push([toAdd[i][0], toAdd[i][1]]);
|
||||
}
|
||||
yield Zotero.DB.queryAsync(
|
||||
sql + toAdd.map(x => "(?, ?, ?)").join(", "),
|
||||
toAdd.map(x => [this.id, x[0], x[1]])
|
||||
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
||||
toAdd,
|
||||
Math.floor(Zotero.DB.MAX_BOUND_PARAMETERS / 3),
|
||||
async function (chunk) {
|
||||
await Zotero.DB.queryAsync(
|
||||
sql + chunk.map(x => "(?, ?, ?)").join(", "),
|
||||
chunk.map(x => [this.id, x[0], x[1]])
|
||||
.reduce((x, y) => x.concat(y))
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
if (toRemove.length) {
|
||||
|
|
Loading…
Reference in a new issue