From b6700849259fe2f8cebe6abb7f2b9ceaf370bef9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 24 Nov 2014 22:59:42 -0500 Subject: [PATCH] Use 'version' for groups instead of 'etag' APIv3 uses 'version' --- chrome/content/zotero/xpcom/data/group.js | 12 ++++++------ chrome/content/zotero/xpcom/schema.js | 4 ++-- resource/schema/userdata.sql | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index 5ae33619e..9ad57bc3c 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -39,7 +39,7 @@ Zotero.Group.prototype._init = function () { this._description = null; this._editable = null; this._filesEditable = null; - this._etag = null; + this._version = null; this._loaded = false; this._changed = false; @@ -61,8 +61,8 @@ Zotero.Group.prototype.__defineGetter__('editable', function () { return this._g Zotero.Group.prototype.__defineSetter__('editable', function (val) { this._set('editable', val); }); Zotero.Group.prototype.__defineGetter__('filesEditable', function () { if (!this.editable) { return false; } return this._get('filesEditable'); }); Zotero.Group.prototype.__defineSetter__('filesEditable', function (val) { this._set('filesEditable', val); }); -Zotero.Group.prototype.__defineGetter__('etag', function () { return this._get('etag'); }); -Zotero.Group.prototype.__defineSetter__('etag', function (val) { this._set('etag', val); }); +Zotero.Group.prototype.__defineGetter__('version', function () { return this._get('version'); }); +Zotero.Group.prototype.__defineSetter__('version', function (val) { this._set('version', val); }); Zotero.Group.prototype._get = function (field) { if (this['_' + field] !== null) { @@ -143,7 +143,7 @@ Zotero.Group.prototype.loadFromRow = function(row) { this._description = row.description; this._editable = !!row.editable; this._filesEditable = !!row.filesEditable; - this._etag = row.etag; + this._version = row.version; } @@ -247,7 +247,7 @@ Zotero.Group.prototype.save = function () { 'description', 'editable', 'filesEditable', - 'etag' + 'version' ]; var placeholders = columns.map(function () '?').join(); var sqlValues = [ @@ -257,7 +257,7 @@ Zotero.Group.prototype.save = function () { this.description, this.editable ? 1 : 0, this.filesEditable ? 1 : 0, - this.etag + this.version ]; if (isNew) { diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index dc79032b5..82e098ad4 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -2003,8 +2003,8 @@ Zotero.Schema = new function(){ yield Zotero.DB.queryAsync("CREATE INDEX relations_object ON relations(object)"); yield Zotero.DB.queryAsync("ALTER TABLE groups RENAME TO groupsOld"); - yield Zotero.DB.queryAsync("CREATE TABLE groups (\n groupID INTEGER PRIMARY KEY,\n libraryID INT NOT NULL UNIQUE,\n name TEXT NOT NULL,\n description TEXT NOT NULL,\n editable INT NOT NULL,\n filesEditable INT NOT NULL,\n etag TEXT NOT NULL DEFAULT '',\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)"); - yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO groups SELECT groupID, libraryID, name, description, editable, filesEditable, '' FROM groupsOld"); + yield Zotero.DB.queryAsync("CREATE TABLE groups (\n groupID INTEGER PRIMARY KEY,\n libraryID INT NOT NULL UNIQUE,\n name TEXT NOT NULL,\n description TEXT NOT NULL,\n editable INT NOT NULL,\n filesEditable INT NOT NULL,\n version INT NOT NULL,\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)"); + yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO groups SELECT groupID, libraryID, name, description, editable, filesEditable, 0 FROM groupsOld"); yield Zotero.DB.queryAsync("ALTER TABLE groupItems RENAME TO groupItemsOld"); yield Zotero.DB.queryAsync("CREATE TABLE groupItems (\n itemID INTEGER PRIMARY KEY,\n createdByUserID INT,\n lastModifiedByUserID INT,\n FOREIGN KEY (itemID) REFERENCES items(itemID) ON DELETE CASCADE,\n FOREIGN KEY (createdByUserID) REFERENCES users(userID) ON DELETE SET NULL,\n FOREIGN KEY (lastModifiedByUserID) REFERENCES users(userID) ON DELETE SET NULL\n)"); diff --git a/resource/schema/userdata.sql b/resource/schema/userdata.sql index fc304b664..97cbc8fd4 100644 --- a/resource/schema/userdata.sql +++ b/resource/schema/userdata.sql @@ -245,7 +245,7 @@ CREATE TABLE groups ( description TEXT NOT NULL, editable INT NOT NULL, filesEditable INT NOT NULL, - etag TEXT NOT NULL DEFAULT '', + version INT NOT NULL, FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE );