From fda5df9a82a085786d9413dd5a30ee39cadcedd4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 21 Dec 2019 05:08:32 -0500 Subject: [PATCH] Fix display of editors in Creator column in new databases Regression in 5.0.78 --- chrome/content/zotero/xpcom/data/items.js | 31 +++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 8290247911..2323f0f090 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -1243,6 +1243,9 @@ Zotero.Items = function() { return _firstCreatorSQL; } + var editorCreatorTypeID = Zotero.CreatorTypes.getID('editor'); + var contributorCreatorTypeID = Zotero.CreatorTypes.getID('contributor'); + /* This whole block is to get the firstCreator */ var localizedAnd = Zotero.getString('general.and'); var localizedEtAl = Zotero.getString('general.etAl'); @@ -1285,50 +1288,58 @@ Zotero.Items = function() { // Then try editors "CASE (" + - "SELECT COUNT(*) FROM itemCreators WHERE itemID=O.itemID AND creatorTypeID IN (3)" + + "SELECT COUNT(*) FROM itemCreators " + + `WHERE itemID=O.itemID AND creatorTypeID=${editorCreatorTypeID}` + ") " + "WHEN 0 THEN NULL " + "WHEN 1 THEN (" + "SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (3)" + + `WHERE itemID=O.itemID AND creatorTypeID=${editorCreatorTypeID}` + ") " + "WHEN 2 THEN (" + "SELECT " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (3) ORDER BY orderIndex LIMIT 1)" + + `WHERE itemID=O.itemID AND creatorTypeID=${editorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1)" + " || ' " + localizedAnd + " ' || " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (3) ORDER BY orderIndex LIMIT 1,1) " + + `WHERE itemID=O.itemID AND creatorTypeID=${editorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1,1) " + ") " + "ELSE (" + "SELECT " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (3) ORDER BY orderIndex LIMIT 1)" + + `WHERE itemID=O.itemID AND creatorTypeID=${editorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1)" + " || ' " + localizedEtAl + "' " + ") " + "END, " + // Then try contributors "CASE (" + - "SELECT COUNT(*) FROM itemCreators WHERE itemID=O.itemID AND creatorTypeID IN (2)" + + "SELECT COUNT(*) FROM itemCreators " + + `WHERE itemID=O.itemID AND creatorTypeID=${contributorCreatorTypeID}` + ") " + "WHEN 0 THEN NULL " + "WHEN 1 THEN (" + "SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (2)" + + `WHERE itemID=O.itemID AND creatorTypeID=${contributorCreatorTypeID}` + ") " + "WHEN 2 THEN (" + "SELECT " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (2) ORDER BY orderIndex LIMIT 1)" + + `WHERE itemID=O.itemID AND creatorTypeID=${contributorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1)" + " || ' " + localizedAnd + " ' || " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (2) ORDER BY orderIndex LIMIT 1,1) " + + `WHERE itemID=O.itemID AND creatorTypeID=${contributorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1,1) " + ") " + "ELSE (" + "SELECT " + "(SELECT lastName FROM itemCreators NATURAL JOIN creators " + - "WHERE itemID=O.itemID AND creatorTypeID IN (2) ORDER BY orderIndex LIMIT 1)" + + `WHERE itemID=O.itemID AND creatorTypeID=${contributorCreatorTypeID} ` + + "ORDER BY orderIndex LIMIT 1)" + " || ' " + localizedEtAl + "' " + ") " + "END" +