Fix upgrade error "counts[0] is undefined" (or "counts[1]")

This commit is contained in:
Dan Stillman 2009-03-17 08:23:45 +00:00
parent 505d3e6ac7
commit 551c8a36a7

View file

@ -1725,9 +1725,13 @@ Zotero.Schema = new function(){
continue;
}
// Use most frequent
var counts = Zotero.DB.query("SELECT tag, COUNT(*) AS numItems FROM tags NATURAL JOIN itemTags WHERE tag LIKE ? GROUP BY tag ORDER BY numItems DESC", l);
if (counts[0].numItems != counts[1].numItems) {
// If not associated with any items, use all lowercase
if (!counts) {
var newTag = l;
}
// Use most frequent
else if (counts[0].numItems != counts[1].numItems) {
var newTag = counts[0].tag;
}
// Use earliest