Commit 2bf93f6e authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Try improving `isSharedWith`

This commit tries to improve the `isSharedWith` SQL function to deal
with arbitrarily deep shared nodes in the hierarchy.
parent cecb48e8
Pipeline #5298 passed with stages
in 69 minutes and 39 seconds
......@@ -398,15 +398,21 @@ isSharedWith targetNode targetUserNode = (== [Only True])
SELECT nn.node1_id, nn.node2_id
FROM nodes_nodes nn
JOIN SharePath sp ON nn.node1_id = sp.shared_node_id
),
UpwardPath AS (
SELECT ? AS current_node_id, parent_id
FROM nodes
WHERE id = ?
UNION ALL
SELECT up.parent_id, n.parent_id
FROM UpwardPath up
JOIN nodes n ON up.parent_id = n.id
)
SELECT
EXISTS (
SELECT 1
FROM nodes n
JOIN SharePath sp ON n.parent_id = sp.shared_node_id
WHERE n.id = ?
OR n.parent_id = ?
FROM UpwardPath up
JOIN SharePath sp ON up.current_node_id = sp.shared_node_id
) AS share_exists;
|] (targetUserNode, targetNode, targetNode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment