From f2cc2204c9de6603817fce01869b051039d61d2a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 21 Jun 2017 06:50:21 -0400 Subject: [PATCH] Fix for some child items not showing up https://forums.zotero.org/discussion/66140/5-0-beta-missing-item-attachments --- chrome/content/zotero/xpcom/data/items.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 397b31648d..537f081074 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -526,11 +526,12 @@ Zotero.Items = function() { + "LEFT JOIN itemDataValues IDV USING (valueID) " + "LEFT JOIN deletedItems DI USING (itemID) " + "WHERE libraryID=?" - + (ids.length ? " AND parentItemID IN (" + ids.map(id => parseInt(id)).join(", ") + ")" : ""); + + (ids.length ? " AND parentItemID IN (" + ids.map(id => parseInt(id)).join(", ") + ")" : "") + + " ORDER BY parentItemID"; // Since we do the sort here and cache these results, a restart will be required // if this pref (off by default) is turned on, but that's OK if (Zotero.Prefs.get('sortAttachmentsChronologically')) { - sql += " ORDER BY parentItemID, dateAdded"; + sql += ", dateAdded"; } var setAttachmentItem = function (itemID, rows) { var item = this._objectCache[itemID]; @@ -575,9 +576,10 @@ Zotero.Items = function() { + "JOIN items I ON (N.parentItemID=I.itemID) " + "LEFT JOIN deletedItems DI USING (itemID) " + "WHERE libraryID=?" - + (ids.length ? " AND parentItemID IN (" + ids.map(id => parseInt(id)).join(", ") + ")" : ""); + + (ids.length ? " AND parentItemID IN (" + ids.map(id => parseInt(id)).join(", ") + ")" : "") + + " ORDER BY parentItemID"; if (Zotero.Prefs.get('sortNotesChronologically')) { - sql += " ORDER BY parentItemID, dateAdded"; + sql += ", dateAdded"; } var setNoteItem = function (itemID, rows) { var item = this._objectCache[itemID];