This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a recursive CTE to turn the join table into a (partial) closure table, | |
# then join all of the child records for the provided parent(s) | |
query = """ | |
WITH RECURSIVE traversal(depth, parent_id, child_id) AS ( | |
SELECT | |
1 depth, | |
parent_id, | |
child_id | |
FROM rules_rules | |
WHERE parent_id = ANY($1) |