Fix no such column: IA.authorName
error from early 6.0 beta upgrade
Fixes #3013
This commit is contained in:
parent
8ac77bf9f0
commit
1f45c44b86
2 changed files with 61 additions and 45 deletions
|
@ -500,55 +500,68 @@ Zotero.Items = function() {
|
||||||
+ "FROM items JOIN itemAnnotations IA USING (itemID) "
|
+ "FROM items JOIN itemAnnotations IA USING (itemID) "
|
||||||
+ "WHERE libraryID=?" + idSQL;
|
+ "WHERE libraryID=?" + idSQL;
|
||||||
var params = [libraryID];
|
var params = [libraryID];
|
||||||
await Zotero.DB.queryAsync(
|
|
||||||
sql,
|
// TEMP: Fix faulty upgrade from early 6.0 beta
|
||||||
params,
|
// https://github.com/zotero/zotero/issues/3013
|
||||||
{
|
try {
|
||||||
noCache: true,
|
await Zotero.DB.queryAsync(
|
||||||
onRow: function (row) {
|
sql,
|
||||||
let itemID = row.getResultByIndex(0);
|
params,
|
||||||
|
{
|
||||||
let item = this._objectCache[itemID];
|
noCache: true,
|
||||||
if (!item) {
|
onRow: function (row) {
|
||||||
throw new Error("Item " + itemID + " not found");
|
let itemID = row.getResultByIndex(0);
|
||||||
}
|
|
||||||
|
|
||||||
item._parentItemID = row.getResultByIndex(1);
|
|
||||||
var typeID = row.getResultByIndex(2);
|
|
||||||
var type;
|
|
||||||
switch (typeID) {
|
|
||||||
case Zotero.Annotations.ANNOTATION_TYPE_HIGHLIGHT:
|
|
||||||
type = 'highlight';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Zotero.Annotations.ANNOTATION_TYPE_NOTE:
|
let item = this._objectCache[itemID];
|
||||||
type = 'note';
|
if (!item) {
|
||||||
break;
|
throw new Error("Item " + itemID + " not found");
|
||||||
|
}
|
||||||
|
|
||||||
case Zotero.Annotations.ANNOTATION_TYPE_IMAGE:
|
item._parentItemID = row.getResultByIndex(1);
|
||||||
type = 'image';
|
var typeID = row.getResultByIndex(2);
|
||||||
break;
|
var type;
|
||||||
|
switch (typeID) {
|
||||||
|
case Zotero.Annotations.ANNOTATION_TYPE_HIGHLIGHT:
|
||||||
|
type = 'highlight';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zotero.Annotations.ANNOTATION_TYPE_NOTE:
|
||||||
|
type = 'note';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zotero.Annotations.ANNOTATION_TYPE_IMAGE:
|
||||||
|
type = 'image';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Zotero.Annotations.ANNOTATION_TYPE_INK:
|
||||||
|
type = 'ink';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown annotation type id ${typeID}`);
|
||||||
|
}
|
||||||
|
item._annotationType = type;
|
||||||
|
item._annotationAuthorName = row.getResultByIndex(3);
|
||||||
|
item._annotationText = row.getResultByIndex(4);
|
||||||
|
item._annotationComment = row.getResultByIndex(5);
|
||||||
|
item._annotationColor = row.getResultByIndex(6);
|
||||||
|
item._annotationSortIndex = row.getResultByIndex(7);
|
||||||
|
item._annotationIsExternal = !!row.getResultByIndex(8);
|
||||||
|
|
||||||
case Zotero.Annotations.ANNOTATION_TYPE_INK:
|
item._loaded.annotation = true;
|
||||||
type = 'ink';
|
item._clearChanged('annotation');
|
||||||
break;
|
}.bind(this)
|
||||||
|
}
|
||||||
default:
|
);
|
||||||
throw new Error(`Unknown annotation type id ${typeID}`);
|
}
|
||||||
}
|
catch (e) {
|
||||||
item._annotationType = type;
|
if (e.message.includes('no such column: IA.authorName')
|
||||||
item._annotationAuthorName = row.getResultByIndex(3);
|
&& await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM version WHERE schema='userdata' AND version=120")) {
|
||||||
item._annotationText = row.getResultByIndex(4);
|
await Zotero.DB.queryAsync("UPDATE version SET version=119 WHERE schema='userdata'");
|
||||||
item._annotationComment = row.getResultByIndex(5);
|
Zotero.crash();
|
||||||
item._annotationColor = row.getResultByIndex(6);
|
|
||||||
item._annotationSortIndex = row.getResultByIndex(7);
|
|
||||||
item._annotationIsExternal = !!row.getResultByIndex(8);
|
|
||||||
|
|
||||||
item._loaded.annotation = true;
|
|
||||||
item._clearChanged('annotation');
|
|
||||||
}.bind(this)
|
|
||||||
}
|
}
|
||||||
);
|
throw e;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3466,6 +3466,9 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TEMP: When adding 121, check whether IA.authorName fix in items.js::_loadAnnotations()
|
||||||
|
// should be updated
|
||||||
|
|
||||||
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
|
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue