www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 2db41b0adc136df9b026a0890dd31409ec91505d
parent 7bd8f47dac5e2223b177bd4d69774b4180e7e13f
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 27 Apr 2017 22:25:26 -0400

Don't update various primary fields unnecessarily during save

Diffstat:
Mchrome/content/zotero/xpcom/data/dataObject.js | 21+++++++++++++--------
Mchrome/content/zotero/xpcom/data/item.js | 15+++++++--------
2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js @@ -930,14 +930,19 @@ Zotero.DataObject.prototype._saveData = function (env) { var libraryID = env.libraryID = this.libraryID || Zotero.Libraries.userLibraryID; var key = env.key = this._key = this.key ? this.key : this._generateKey(); - env.sqlColumns = [ - 'libraryID', - 'key' - ]; - env.sqlValues = [ - libraryID, - key - ]; + env.sqlColumns = []; + env.sqlValues = []; + + if (env.isNew) { + env.sqlColumns.push( + 'libraryID', + 'key' + ); + env.sqlValues.push( + libraryID, + key + ); + } if (this._changed.primaryData && this._changed.primaryData.version) { env.sqlColumns.push('version'); diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -1244,14 +1244,10 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { // If available id value, use it -- otherwise we'll use autoincrement var itemID = this._id = this.id ? this.id : Zotero.ID.get('items'); - env.sqlColumns.push( - 'itemTypeID', - 'dateAdded' - ); - env.sqlValues.push( - { int: itemTypeID }, - this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime - ); + if (this._changed.primaryData && this._changed.primaryData.itemTypeID) { + env.sqlColumns.push('itemTypeID'); + env.sqlValues.push({ int: itemTypeID }); + } // If a new item and Date Modified hasn't been provided, or an existing item and // Date Modified hasn't changed from its previous value and skipDateModifiedUpdate wasn't @@ -1271,6 +1267,9 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { } if (isNew) { + env.sqlColumns.push('dateAdded'); + env.sqlValues.push(this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime); + env.sqlColumns.unshift('itemID'); env.sqlValues.unshift(parseInt(itemID));