Don't show items with annotated attachments after moving to trash
https://forums.zotero.org/discussion/100775/deleted-items-keep-reappearing-in-my-library
Regression from 20c6fe67
This commit is contained in:
parent
deb5d1cd27
commit
f33cf1cde3
2 changed files with 46 additions and 8 deletions
|
@ -1097,16 +1097,24 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
||||||
|
|
||||||
// Exclude deleted items (and their child items) by default
|
// Exclude deleted items (and their child items) by default
|
||||||
let not = deleted ? "" : "NOT ";
|
let not = deleted ? "" : "NOT ";
|
||||||
let op = deleted ? "OR" : "AND";
|
sql += ` WHERE (itemID ${not} IN (`
|
||||||
sql += " WHERE ("
|
// Deleted items
|
||||||
+ `itemID ${not} IN (SELECT itemID FROM deletedItems) `
|
+ "SELECT itemID FROM deletedItems "
|
||||||
+ `${op} itemID ${not}IN (SELECT itemID FROM itemNotes `
|
// Child notes of deleted items
|
||||||
|
+ "UNION SELECT itemID FROM itemNotes "
|
||||||
+ "WHERE parentItemID IS NOT NULL AND "
|
+ "WHERE parentItemID IS NOT NULL AND "
|
||||||
+ "parentItemID IN (SELECT itemID FROM deletedItems)) "
|
+ "parentItemID IN (SELECT itemID FROM deletedItems) "
|
||||||
+ `${op} itemID ${not}IN (SELECT itemID FROM itemAttachments `
|
// Child attachments of deleted items
|
||||||
|
+ "UNION SELECT itemID FROM itemAttachments "
|
||||||
+ "WHERE parentItemID IS NOT NULL AND "
|
+ "WHERE parentItemID IS NOT NULL AND "
|
||||||
+ "parentItemID IN (SELECT itemID FROM deletedItems))"
|
+ "parentItemID IN (SELECT itemID FROM deletedItems)"
|
||||||
+ ")";
|
// Annotations of deleted attachments
|
||||||
|
+ "UNION SELECT itemID FROM itemAnnotations "
|
||||||
|
+ "WHERE parentItemID IN (SELECT itemID FROM deletedItems)"
|
||||||
|
// Annotations of attachments of deleted items
|
||||||
|
+ "UNION SELECT itemID FROM itemAnnotations "
|
||||||
|
+ "WHERE parentItemID IN (SELECT itemID FROM itemAttachments WHERE parentItemID IN (SELECT itemID FROM deletedItems))"
|
||||||
|
+ "))";
|
||||||
|
|
||||||
if (noChildren){
|
if (noChildren){
|
||||||
sql += " AND (itemID NOT IN (SELECT itemID FROM itemNotes "
|
sql += " AND (itemID NOT IN (SELECT itemID FROM itemNotes "
|
||||||
|
|
|
@ -610,6 +610,36 @@ describe("Zotero.Search", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("deleted", function () {
|
||||||
|
describe("if not present", function () {
|
||||||
|
it("should not match regular items in trash with annotated child attachments", async function () {
|
||||||
|
var item = await createDataObject('item');
|
||||||
|
item.deleted = true;
|
||||||
|
await item.saveTx();
|
||||||
|
var attachment = await importPDFAttachment(item);
|
||||||
|
await createAnnotation('highlight', attachment);
|
||||||
|
|
||||||
|
var s = new Zotero.Search();
|
||||||
|
s.libraryID = userLibraryID;
|
||||||
|
var matches = await s.search();
|
||||||
|
assert.notInclude(matches, attachment.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not match regular items with annotated child attachments in trash", async function () {
|
||||||
|
var item = await createDataObject('item');
|
||||||
|
var attachment = await importPDFAttachment(item);
|
||||||
|
attachment.deleted = true;
|
||||||
|
await attachment.saveTx();
|
||||||
|
await createAnnotation('highlight', attachment);
|
||||||
|
|
||||||
|
var s = new Zotero.Search();
|
||||||
|
s.libraryID = userLibraryID;
|
||||||
|
var matches = await s.search();
|
||||||
|
assert.notInclude(matches, attachment.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue