mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
check reference issues only for non deleted entities
This commit is contained in:
parent
42112b8053
commit
d8b78d8025
@ -92,38 +92,39 @@ async function findBrokenReferenceIssues() {
|
|||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT branchId, branches.noteId
|
SELECT branchId, branches.noteId
|
||||||
FROM branches LEFT JOIN notes USING(noteId)
|
FROM branches LEFT JOIN notes USING(noteId)
|
||||||
WHERE notes.noteId IS NULL`,
|
WHERE branches.isDeleted = 0 AND notes.noteId IS NULL`,
|
||||||
({branchId, noteId}) => `Branch ${branchId} references missing note ${noteId}`);
|
({branchId, noteId}) => `Branch ${branchId} references missing note ${noteId}`);
|
||||||
|
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT branchId, branches.noteId AS parentNoteId
|
SELECT branchId, branches.noteId AS parentNoteId
|
||||||
FROM branches LEFT JOIN notes ON notes.noteId = branches.parentNoteId
|
FROM branches LEFT JOIN notes ON notes.noteId = branches.parentNoteId
|
||||||
WHERE branches.branchId != 'root' AND notes.noteId IS NULL`,
|
WHERE branches.isDeleted = 0 AND branches.branchId != 'root' AND notes.noteId IS NULL`,
|
||||||
({branchId, noteId}) => `Branch ${branchId} references missing parent note ${noteId}`);
|
({branchId, noteId}) => `Branch ${branchId} references missing parent note ${noteId}`);
|
||||||
|
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT attributeId, attributes.noteId
|
SELECT attributeId, attributes.noteId
|
||||||
FROM attributes LEFT JOIN notes USING(noteId)
|
FROM attributes LEFT JOIN notes USING(noteId)
|
||||||
WHERE notes.noteId IS NULL`,
|
WHERE attributes.isDeleted = 0 AND notes.noteId IS NULL`,
|
||||||
({attributeId, noteId}) => `Attribute ${attributeId} references missing source note ${noteId}`);
|
({attributeId, noteId}) => `Attribute ${attributeId} references missing source note ${noteId}`);
|
||||||
|
|
||||||
// empty targetNoteId for relations is a special fixable case so not covered here
|
// empty targetNoteId for relations is a special fixable case so not covered here
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT attributeId, attributes.value AS noteId
|
SELECT attributeId, attributes.value AS noteId
|
||||||
FROM attributes LEFT JOIN notes ON notes.noteId = attributes.value
|
FROM attributes LEFT JOIN notes ON notes.noteId = attributes.value
|
||||||
WHERE attributes.type = 'relation' AND attributes.value != '' AND notes.noteId IS NULL`,
|
WHERE attributes.isDeleted = 0 AND attributes.type = 'relation'
|
||||||
|
AND attributes.value != '' AND notes.noteId IS NULL`,
|
||||||
({attributeId, noteId}) => `Relation ${attributeId} references missing note ${noteId}`);
|
({attributeId, noteId}) => `Relation ${attributeId} references missing note ${noteId}`);
|
||||||
|
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT linkId, links.noteId
|
SELECT linkId, links.noteId
|
||||||
FROM links LEFT JOIN notes USING(noteId)
|
FROM links LEFT JOIN notes USING(noteId)
|
||||||
WHERE notes.noteId IS NULL`,
|
WHERE links.isDeleted = 0 AND notes.noteId IS NULL`,
|
||||||
({linkId, noteId}) => `Link ${linkId} references missing source note ${noteId}`);
|
({linkId, noteId}) => `Link ${linkId} references missing source note ${noteId}`);
|
||||||
|
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
SELECT linkId, links.noteId
|
SELECT linkId, links.noteId
|
||||||
FROM links LEFT JOIN notes ON notes.noteId = links.targetNoteId
|
FROM links LEFT JOIN notes ON notes.noteId = links.targetNoteId
|
||||||
WHERE notes.noteId IS NULL`,
|
WHERE links.isDeleted = 0 AND notes.noteId IS NULL`,
|
||||||
({linkId, noteId}) => `Link ${linkId} references missing target note ${noteId}`);
|
({linkId, noteId}) => `Link ${linkId} references missing target note ${noteId}`);
|
||||||
|
|
||||||
await findIssues(`
|
await findIssues(`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user