www

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

commit 43a2045aecff9bf1efcf50841519b1ac2ec85c3e
parent 5070c04af63f5c5bc594f497992f517dd77b8a92
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  1 May 2015 12:41:41 -0400

Change computerProgram 'version' to 'versionNumber'

And use 'version' instead of 'itemVersion' for object version for items

Also add deferred foreign key checking to system.sql so that DROP TABLE
commands don't fail mid-transaction

Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 17++++++++---------
Mchrome/content/zotero/xpcom/data/items.js | 3+--
Mchrome/locale/en-US/zotero/zotero.properties | 2+-
Mresource/schema/system.sql | 7+++++--
Mtest/tests/itemTest.js | 20+++++++++++++++++++-
5 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -40,7 +40,6 @@ Zotero.Item = function(itemTypeOrID) { this._itemTypeID = null; this._firstCreator = null; this._sortCreator = null; - this._itemVersion = null; this._numNotes = null; this._numNotesTrashed = null; this._numNotesEmbedded = null; @@ -136,7 +135,7 @@ Zotero.defineProperty(Zotero.Item.prototype, 'dateModified', { set: function(val) this.setField('dateModified', val) }); Zotero.defineProperty(Zotero.Item.prototype, 'version', { - get: function() this._itemVersion, + get: function() this._version, set: function(val) this.setField('version', val) }); Zotero.defineProperty(Zotero.Item.prototype, 'synced', { @@ -344,8 +343,8 @@ Zotero.Item.prototype._parseRowData = function(row) { if (row.dateModified !== undefined) { this._dateModified = row.dateModified; } - if (row.itemVersion !== undefined) { - this._itemVersion = parseInt(row.itemVersion); + if (row.version !== undefined) { + this._version = parseInt(row.version); } if (row.numNotes !== undefined) { this._numNotes = parseInt(row.numNotes); @@ -418,7 +417,7 @@ Zotero.Item.prototype._parseRowData = function(row) { this['_' + col] = val; break; - case 'itemVersion': + case 'version': case 'numNotes': case 'numNotesTrashed': case 'numNotesEmbedded': @@ -4123,8 +4122,8 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options, patc } var obj = {}; - obj.itemKey = this.key; - obj.itemVersion = this.version; + obj.key = this.key; + obj.version = this.version; obj.itemType = Zotero.ItemTypes.getName(this.itemTypeID); // Fields @@ -4217,8 +4216,8 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options, patc if (mode == 'patch') { for (let i in patchBase) { switch (i) { - case 'itemKey': - case 'itemVersion': + case 'key': + case 'version': case 'dateModified': continue; } diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js @@ -43,8 +43,7 @@ Zotero.Items = function() { dateModified: "O.dateModified", libraryID: "O.libraryID", key: "O.key", - // 'itemVersion' because computerProgram has 'version' - itemVersion: "O.version AS itemVersion", + version: "O.version", synced: "O.synced", firstCreator: _getFirstCreatorSQL(), diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -399,7 +399,7 @@ itemFields.runningTime = Running Time itemFields.network = Network itemFields.postType = Post Type itemFields.audioFileType = File Type -itemFields.version = Version +itemFields.versionNumber = Version itemFields.system = System itemFields.company = Company itemFields.conferenceName = Conference Name diff --git a/resource/schema/system.sql b/resource/schema/system.sql @@ -1,4 +1,4 @@ --- 31 +-- 32 -- Copyright (c) 2009 Center for History and New Media -- George Mason University, Fairfax, Virginia, USA @@ -23,6 +23,7 @@ -- This file creates system tables that can be safely wiped and reinitialized -- at any time, as long as existing ids are preserved. +PRAGMA defer_foreign_keys = true; -- Valid item types ("book," "journalArticle," etc.) DROP TABLE IF EXISTS itemTypes; @@ -295,7 +296,7 @@ INSERT INTO fields VALUES (77,'runningTime',NULL); INSERT INTO fields VALUES (78,'network',NULL); INSERT INTO fields VALUES (79,'postType',NULL); INSERT INTO fields VALUES (80,'audioFileType',NULL); -INSERT INTO fields VALUES (81,'version',NULL); +INSERT INTO fields VALUES (81,'versionNumber',NULL); INSERT INTO fields VALUES (82,'system',NULL); INSERT INTO fields VALUES (83,'company',NULL); INSERT INTO fields VALUES (84,'conferenceName',NULL); @@ -1185,3 +1186,5 @@ INSERT INTO "syncObjectTypes" VALUES(4, 'search'); INSERT INTO "syncObjectTypes" VALUES(5, 'tag'); INSERT INTO "syncObjectTypes" VALUES(6, 'relation'); INSERT INTO "syncObjectTypes" VALUES(7, 'setting'); + +PRAGMA defer_foreign_keys = false; diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js @@ -1,4 +1,4 @@ -describe("Zotero.Item", function() { +describe("Zotero.Item", function () { describe("#getField()", function () { it("should return false for valid unset fields on unsaved items", function* () { var item = new Zotero.Item('book'); @@ -18,6 +18,24 @@ describe("Zotero.Item", function() { }); }); + describe("#setField", function () { + it("should save version as object version", function* () { + var item = new Zotero.Item('book'); + item.setField("version", 1); + var id = yield item.save(); + item = yield Zotero.Items.getAsync(id); + assert.equal(item.getField("version"), 1); + }); + + it("should save versionNumber for computerProgram", function () { + var item = new Zotero.Item('computerProgram'); + item.setField("versionNumber", "1.0"); + var id = yield item.save(); + item = yield Zotero.Items.getAsync(id); + assert.equal(item.getField("versionNumber"), "1.0"); + }); + }) + describe("#parentID", function () { it("should create a child note", function () { return Zotero.DB.executeTransaction(function* () {