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,10 +1102,16 @@ Zotero.DataObject.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
|
||||||
toAdd[i][0] = yield Zotero.RelationPredicates.add(toAdd[i][0]);
|
toAdd[i][0] = yield Zotero.RelationPredicates.add(toAdd[i][0]);
|
||||||
env.relationsToRegister.push([toAdd[i][0], toAdd[i][1]]);
|
env.relationsToRegister.push([toAdd[i][0], toAdd[i][1]]);
|
||||||
}
|
}
|
||||||
yield Zotero.DB.queryAsync(
|
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
||||||
sql + toAdd.map(x => "(?, ?, ?)").join(", "),
|
toAdd,
|
||||||
toAdd.map(x => [this.id, x[0], x[1]])
|
Math.floor(Zotero.DB.MAX_BOUND_PARAMETERS / 3),
|
||||||
.reduce((x, y) => x.concat(y))
|
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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue