From 8f018cc7c69257bbd11590e41e267872e19d7bb6 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 1 Oct 2020 23:42:09 +0200 Subject: [PATCH] as part of tree/note load make sure also relation targets are loaded, closes #1273 --- src/routes/api/tree.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js index 3a775792f..57e1ad915 100644 --- a/src/routes/api/tree.js +++ b/src/routes/api/tree.js @@ -71,8 +71,17 @@ function getTree(req) { JOIN treeWithDescendantsAndAscendants ON branches.noteId = treeWithDescendantsAndAscendants.noteId WHERE branches.isDeleted = 0 AND branches.parentNoteId != ? + ), + treeWithDescendantsAscendantsAndTemplates AS ( + SELECT noteId FROM treeWithDescendantsAndAscendants + UNION + SELECT attributes.value FROM attributes + JOIN treeWithDescendantsAscendantsAndTemplates ON attributes.noteId = treeWithDescendantsAscendantsAndTemplates.noteId + WHERE attributes.isDeleted = 0 + AND attributes.type = 'relation' + AND attributes.name = 'template' ) - SELECT noteId FROM treeWithDescendantsAndAscendants`, [subTreeNoteId, subTreeNoteId]); + SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]); noteIds.push(subTreeNoteId);