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
This commit is contained in:
parent
5070c04af6
commit
43a2045aec
5 changed files with 34 additions and 15 deletions
|
@ -40,7 +40,6 @@ Zotero.Item = function(itemTypeOrID) {
|
||||||
this._itemTypeID = null;
|
this._itemTypeID = null;
|
||||||
this._firstCreator = null;
|
this._firstCreator = null;
|
||||||
this._sortCreator = null;
|
this._sortCreator = null;
|
||||||
this._itemVersion = null;
|
|
||||||
this._numNotes = null;
|
this._numNotes = null;
|
||||||
this._numNotesTrashed = null;
|
this._numNotesTrashed = null;
|
||||||
this._numNotesEmbedded = null;
|
this._numNotesEmbedded = null;
|
||||||
|
@ -136,7 +135,7 @@ Zotero.defineProperty(Zotero.Item.prototype, 'dateModified', {
|
||||||
set: function(val) this.setField('dateModified', val)
|
set: function(val) this.setField('dateModified', val)
|
||||||
});
|
});
|
||||||
Zotero.defineProperty(Zotero.Item.prototype, 'version', {
|
Zotero.defineProperty(Zotero.Item.prototype, 'version', {
|
||||||
get: function() this._itemVersion,
|
get: function() this._version,
|
||||||
set: function(val) this.setField('version', val)
|
set: function(val) this.setField('version', val)
|
||||||
});
|
});
|
||||||
Zotero.defineProperty(Zotero.Item.prototype, 'synced', {
|
Zotero.defineProperty(Zotero.Item.prototype, 'synced', {
|
||||||
|
@ -344,8 +343,8 @@ Zotero.Item.prototype._parseRowData = function(row) {
|
||||||
if (row.dateModified !== undefined) {
|
if (row.dateModified !== undefined) {
|
||||||
this._dateModified = row.dateModified;
|
this._dateModified = row.dateModified;
|
||||||
}
|
}
|
||||||
if (row.itemVersion !== undefined) {
|
if (row.version !== undefined) {
|
||||||
this._itemVersion = parseInt(row.itemVersion);
|
this._version = parseInt(row.version);
|
||||||
}
|
}
|
||||||
if (row.numNotes !== undefined) {
|
if (row.numNotes !== undefined) {
|
||||||
this._numNotes = parseInt(row.numNotes);
|
this._numNotes = parseInt(row.numNotes);
|
||||||
|
@ -418,7 +417,7 @@ Zotero.Item.prototype._parseRowData = function(row) {
|
||||||
this['_' + col] = val;
|
this['_' + col] = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'itemVersion':
|
case 'version':
|
||||||
case 'numNotes':
|
case 'numNotes':
|
||||||
case 'numNotesTrashed':
|
case 'numNotesTrashed':
|
||||||
case 'numNotesEmbedded':
|
case 'numNotesEmbedded':
|
||||||
|
@ -4123,8 +4122,8 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options, patc
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
obj.itemKey = this.key;
|
obj.key = this.key;
|
||||||
obj.itemVersion = this.version;
|
obj.version = this.version;
|
||||||
obj.itemType = Zotero.ItemTypes.getName(this.itemTypeID);
|
obj.itemType = Zotero.ItemTypes.getName(this.itemTypeID);
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
|
@ -4217,8 +4216,8 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options, patc
|
||||||
if (mode == 'patch') {
|
if (mode == 'patch') {
|
||||||
for (let i in patchBase) {
|
for (let i in patchBase) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'itemKey':
|
case 'key':
|
||||||
case 'itemVersion':
|
case 'version':
|
||||||
case 'dateModified':
|
case 'dateModified':
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ Zotero.Items = function() {
|
||||||
dateModified: "O.dateModified",
|
dateModified: "O.dateModified",
|
||||||
libraryID: "O.libraryID",
|
libraryID: "O.libraryID",
|
||||||
key: "O.key",
|
key: "O.key",
|
||||||
// 'itemVersion' because computerProgram has 'version'
|
version: "O.version",
|
||||||
itemVersion: "O.version AS itemVersion",
|
|
||||||
synced: "O.synced",
|
synced: "O.synced",
|
||||||
|
|
||||||
firstCreator: _getFirstCreatorSQL(),
|
firstCreator: _getFirstCreatorSQL(),
|
||||||
|
|
|
@ -399,7 +399,7 @@ itemFields.runningTime = Running Time
|
||||||
itemFields.network = Network
|
itemFields.network = Network
|
||||||
itemFields.postType = Post Type
|
itemFields.postType = Post Type
|
||||||
itemFields.audioFileType = File Type
|
itemFields.audioFileType = File Type
|
||||||
itemFields.version = Version
|
itemFields.versionNumber = Version
|
||||||
itemFields.system = System
|
itemFields.system = System
|
||||||
itemFields.company = Company
|
itemFields.company = Company
|
||||||
itemFields.conferenceName = Conference Name
|
itemFields.conferenceName = Conference Name
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- 31
|
-- 32
|
||||||
|
|
||||||
-- Copyright (c) 2009 Center for History and New Media
|
-- Copyright (c) 2009 Center for History and New Media
|
||||||
-- George Mason University, Fairfax, Virginia, USA
|
-- George Mason University, Fairfax, Virginia, USA
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
-- This file creates system tables that can be safely wiped and reinitialized
|
-- This file creates system tables that can be safely wiped and reinitialized
|
||||||
-- at any time, as long as existing ids are preserved.
|
-- at any time, as long as existing ids are preserved.
|
||||||
|
|
||||||
|
PRAGMA defer_foreign_keys = true;
|
||||||
|
|
||||||
-- Valid item types ("book," "journalArticle," etc.)
|
-- Valid item types ("book," "journalArticle," etc.)
|
||||||
DROP TABLE IF EXISTS itemTypes;
|
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 (78,'network',NULL);
|
||||||
INSERT INTO fields VALUES (79,'postType',NULL);
|
INSERT INTO fields VALUES (79,'postType',NULL);
|
||||||
INSERT INTO fields VALUES (80,'audioFileType',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 (82,'system',NULL);
|
||||||
INSERT INTO fields VALUES (83,'company',NULL);
|
INSERT INTO fields VALUES (83,'company',NULL);
|
||||||
INSERT INTO fields VALUES (84,'conferenceName',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(5, 'tag');
|
||||||
INSERT INTO "syncObjectTypes" VALUES(6, 'relation');
|
INSERT INTO "syncObjectTypes" VALUES(6, 'relation');
|
||||||
INSERT INTO "syncObjectTypes" VALUES(7, 'setting');
|
INSERT INTO "syncObjectTypes" VALUES(7, 'setting');
|
||||||
|
|
||||||
|
PRAGMA defer_foreign_keys = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe("Zotero.Item", function() {
|
describe("Zotero.Item", function () {
|
||||||
describe("#getField()", function () {
|
describe("#getField()", function () {
|
||||||
it("should return false for valid unset fields on unsaved items", function* () {
|
it("should return false for valid unset fields on unsaved items", function* () {
|
||||||
var item = new Zotero.Item('book');
|
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 () {
|
describe("#parentID", function () {
|
||||||
it("should create a child note", function () {
|
it("should create a child note", function () {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(function* () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue