Fix dragging of items with old creators with NULL values into group libraries, and store (currently unused) shortName and birthYear fields as '' and NULL, respectively
This commit is contained in:
parent
643376769a
commit
7ab0a62e38
|
@ -34,7 +34,7 @@ Zotero.Creators = new function() {
|
||||||
this.erase = erase;
|
this.erase = erase;
|
||||||
this.purge = purge;
|
this.purge = purge;
|
||||||
|
|
||||||
this.fields = ['firstName', 'lastName', 'fieldMode', 'birthYear'];
|
this.__defineGetter__('fields', function () ['firstName', 'lastName', 'shortName', 'fieldMode', 'birthYear']);
|
||||||
|
|
||||||
var _creatorDataHash = {}; // creatorDataIDs indexed by md5 hash of data
|
var _creatorDataHash = {}; // creatorDataIDs indexed by md5 hash of data
|
||||||
|
|
||||||
|
@ -82,15 +82,12 @@ Zotero.Creators = new function() {
|
||||||
return _creatorDataHash[hash];
|
return _creatorDataHash[hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.DB.beginTransaction();
|
var params = [];
|
||||||
|
for each(var field in fields) {
|
||||||
|
params.push(field);
|
||||||
|
}
|
||||||
|
|
||||||
var params = [
|
Zotero.DB.beginTransaction();
|
||||||
fields.firstName,
|
|
||||||
fields.lastName,
|
|
||||||
'',
|
|
||||||
fields.fieldMode,
|
|
||||||
fields.birthYear
|
|
||||||
];
|
|
||||||
|
|
||||||
var sql = "SELECT creatorDataID FROM creatorData WHERE "
|
var sql = "SELECT creatorDataID FROM creatorData WHERE "
|
||||||
+ "firstName=? AND lastName=? AND shortName=? "
|
+ "firstName=? AND lastName=? AND shortName=? "
|
||||||
|
@ -303,31 +300,24 @@ Zotero.Creators = new function() {
|
||||||
|
|
||||||
|
|
||||||
function _cleanFields(fields) {
|
function _cleanFields(fields) {
|
||||||
var cleanedFields = {
|
var cleanedFields = {};
|
||||||
firstName: '',
|
for each(var field in Zotero.Creators.fields) {
|
||||||
lastName: '',
|
switch (field) {
|
||||||
fieldMode: 0,
|
// Strings
|
||||||
birthYear: ''
|
case 'firstName':
|
||||||
};
|
case 'lastName':
|
||||||
for (var field in fields) {
|
case 'shortName':
|
||||||
if (fields[field]) {
|
cleanedFields[field] = fields[field] ? fields[field] + '' : '';
|
||||||
switch (field) {
|
break;
|
||||||
// Strings
|
|
||||||
case 'firstName':
|
|
||||||
case 'lastName':
|
|
||||||
case 'shortName':
|
|
||||||
cleanedFields[field] = fields[field] + '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Integer
|
// Integer
|
||||||
case 'fieldMode':
|
case 'fieldMode':
|
||||||
cleanedFields[field] = fields[field] ? fields[field] : 0;
|
cleanedFields[field] = fields[field] ? fields[field] : 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Null if empty
|
// Null if empty
|
||||||
default:
|
case 'birthYear':
|
||||||
cleanedFields[field] = fields[field] ? fields[field] : null;
|
cleanedFields[field] = fields[field] ? fields[field] : null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cleanedFields;
|
return cleanedFields;
|
||||||
|
|
|
@ -2367,6 +2367,11 @@ Zotero.Schema = new function(){
|
||||||
if (i==53) {
|
if (i==53) {
|
||||||
Zotero.DB.query("DELETE FROM collectionItems WHERE itemID IN (SELECT itemID FROM items WHERE itemID IN (SELECT itemID FROM itemAttachments WHERE sourceItemID IS NOT NULL) OR itemID IN (SELECT itemID FROM itemNotes WHERE sourceItemID IS NOT NULL))");
|
Zotero.DB.query("DELETE FROM collectionItems WHERE itemID IN (SELECT itemID FROM items WHERE itemID IN (SELECT itemID FROM itemAttachments WHERE sourceItemID IS NOT NULL) OR itemID IN (SELECT itemID FROM itemNotes WHERE sourceItemID IS NOT NULL))");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i==54) {
|
||||||
|
Zotero.DB.query("UPDATE creatorData SET shortName='' WHERE shortName IS NULL");
|
||||||
|
Zotero.DB.query("UPDATE creatorData SET birthYear=NULL WHERE birthYear=''");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateDBVersion('userdata', toVersion);
|
_updateDBVersion('userdata', toVersion);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- 53
|
-- 54
|
||||||
|
|
||||||
-- This file creates tables containing user-specific data for new users --
|
-- This file creates tables containing user-specific data for new users --
|
||||||
-- any changes made here must be mirrored in transition steps in schema.js::_migrateSchema()
|
-- any changes made here must be mirrored in transition steps in schema.js::_migrateSchema()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user