diff --git a/server/nm-store/src/sql/select_note_collection_from_root.sql b/server/nm-store/src/sql/select_note_collection_from_root.sql index 9625e64..e055f58 100644 --- a/server/nm-store/src/sql/select_note_collection_from_root.sql +++ b/server/nm-store/src/sql/select_note_collection_from_root.sql @@ -13,10 +13,10 @@ -- *in nesting order* to the client. SELECT + id, + uuid, parent_id, parent_uuid, - note_id, - note_uuid, content, position, notetype, @@ -28,10 +28,10 @@ SELECT FROM ( WITH RECURSIVE notetree( - parent_id, - parent_uuid, id, uuid, + parent_id, + parent_uuid, content, position, notetype, @@ -42,11 +42,11 @@ FROM ( cycle) AS -- ROOT expression - SELECT - notes.id, - notes.uuid, + (SELECT notes.id, notes.uuid, + notes.id AS parent_id, + notes.uuid AS parent_uuid, notes.content, 0, -- Root notes are always in position 0 notes.notetype, @@ -60,10 +60,10 @@ FROM ( -- RECURSIVE expression UNION SELECT - notetree.id, - notetree.uuid, notes.id, notes.uuid, + notetree.id AS parent_id, + notetree.uuid AS parent_uuid, notes.content, note_relationships.position, notes.notetype, @@ -81,5 +81,6 @@ FROM ( -- be; we're supposed to prevent those. But you never know. WHERE notetree.cycle NOT LIKE '%,'||notes.id||',%' - ORDER BY note_relationships.position); + ORDER BY note_relationships.position) + SELECT * from notetree);