Fix sync error downloading new item with related item

This commit is contained in:
Dan Stillman 2013-02-07 17:36:37 -05:00
parent ce12c999ca
commit e157d8bc57

View file

@ -1546,26 +1546,10 @@ Zotero.Item.prototype.save = function() {
var newids = [];
var currentIDs = this._getRelatedItems(true);
for each(var id in this._previousData.related) {
if (currentIDs.indexOf(id) == -1) {
removed.push(id);
}
}
for each(var id in currentIDs) {
if (this._previousData.related.indexOf(id) != -1) {
continue;
}
newids.push(id);
}
if (removed.length) {
var sql = "DELETE FROM itemSeeAlso WHERE itemID=? "
+ "AND linkedItemID IN ("
+ removed.map(function () '?').join()
+ ")";
Zotero.DB.query(sql, [itemID].concat(removed));
}
if (newids.length) {
var sql = "INSERT INTO itemSeeAlso (itemID, linkedItemID) VALUES (?,?)";
var insertStatement = Zotero.DB.getStatement(sql);