diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index ad25464f89..520ab91923 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -140,6 +140,7 @@ Zotero.Collection.prototype.loadFromRow = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 029e0332c6..35aefe9667 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -375,6 +375,7 @@ Zotero.Item.prototype._parseRowData = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/chrome/content/zotero/xpcom/data/search.js b/chrome/content/zotero/xpcom/data/search.js index e10b7d1c06..283945027f 100644 --- a/chrome/content/zotero/xpcom/data/search.js +++ b/chrome/content/zotero/xpcom/data/search.js @@ -143,6 +143,7 @@ Zotero.Search.prototype.loadFromRow = function (row) { // Integer or 0 case 'version': + case 'clientVersion': val = val ? parseInt(val) : 0; break; diff --git a/test/tests/dataObjectTest.js b/test/tests/dataObjectTest.js index 2837a666b6..de371967e5 100644 --- a/test/tests/dataObjectTest.js +++ b/test/tests/dataObjectTest.js @@ -61,6 +61,21 @@ describe("Zotero.DataObject", function () { } }); + it("should load 0 as a number", async function () { + for (let type of types) { + let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type); + let obj = await createDataObject(type); + let id = obj.id; + await Zotero.DB.queryAsync( + `UPDATE ${objectsClass.table} SET clientVersion=0 WHERE ${objectsClass.idColumn}=?`, + id + ); + objectsClass.unload(id); + obj = await objectsClass.getAsync(id); + assert.strictEqual(obj.clientVersion, 0, type + " clientVersion mismatch"); + } + }); + it("should increase after modifying object", async function () { for (let type of types) { let obj = await createDataObject(type);