Skip to content

Commit

Permalink
fix: exclude the original config
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Mar 15, 2024
1 parent 86f63c6 commit dc09707
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions views/006_config_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,15 @@ CREATE OR REPLACE FUNCTION related_config_ids_recursive (
AND deleted_at IS NULL
UNION ALL
SELECT
child.related_id, parent.config_id as related_id, child.relation, parent.depth +1
FROM config_relationships child, cte parent
child.related_id, parent.config_id as related_id, child.relation, parent.depth + 1
FROM config_relationships child, cte parent
WHERE child.config_id = parent.config_id
AND parent.depth <= max_depth
AND deleted_at IS NULL
) CYCLE config_id SET is_cycle USING path
SELECT DISTINCT cte.config_id, cte.related_id, cte.relation, type_filter, cte.depth
FROM cte
WHERE cte.config_id <> related_config_ids_recursive.config_id
ORDER BY cte.depth asc;
ELSIF type_filter = 'incoming' THEN
RETURN query
Expand All @@ -459,6 +460,7 @@ CREATE OR REPLACE FUNCTION related_config_ids_recursive (
) CYCLE config_id SET is_cycle USING path
SELECT DISTINCT cte.config_id, cte.related_id, cte.relation,type_filter,cte.depth
FROM cte
WHERE cte.config_id <> related_config_ids_recursive.config_id
ORDER BY cte.depth asc;
ELSE
RETURN query
Expand Down

0 comments on commit dc09707

Please sign in to comment.