Skip to content

Commit 0b9ed33

Browse files
committed
Only treat root libs as mounts.
1 parent c4f92a5 commit 0b9ed33

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

sql/2025-12-03_only-root-libs.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Replace existing dependency_mounts function to only create 'lib' mounts at the root level.
2+
CREATE OR REPLACE FUNCTION create_dependency_mounts(root_namespace_hash_id INTEGER)
3+
RETURNS TABLE (mount_path TEXT, reversed_mount_path TEXT, namespace_hash_id INTEGER) AS $$
4+
BEGIN
5+
-- Find all child namespaces so we can determine which ones are dependency mounts:
6+
RETURN QUERY WITH lib_mounts(mount_path, reversed_mount_path, namespace_hash_id) AS (
7+
SELECT 'lib.' || child_name_segment.text || '.', child_name_segment.text || '.lib.', child_causal.namespace_hash_id
8+
FROM namespace_children lib
9+
JOIN text lib_name_segment ON lib.name_segment_id = lib_name_segment.id
10+
JOIN causals lib_causal ON lib.child_causal_id = lib_causal.id
11+
JOIN namespace_children child_namespace ON lib_causal.namespace_hash_id = child_namespace.parent_namespace_hash_id
12+
JOIN causals child_causal ON child_namespace.child_causal_id = child_causal.id
13+
JOIN text child_name_segment ON child_namespace.name_segment_id = child_name_segment.id
14+
WHERE lib.parent_namespace_hash_id = root_namespace_hash_id
15+
AND lib_name_segment.text = 'lib'
16+
)
17+
INSERT INTO name_lookup_mounts AS nlm (parent_root_branch_hash_id, mounted_root_branch_hash_id, mount_path, reversed_mount_path)
18+
SELECT root_namespace_hash_id, lib_mounts.namespace_hash_id, lib_mounts.mount_path, lib_mounts.reversed_mount_path
19+
FROM lib_mounts
20+
RETURNING nlm.mount_path, nlm.reversed_mount_path, nlm.mounted_root_branch_hash_id;
21+
END;
22+
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)