Get the latest tech news
Waiting for PostgreSQL 14: SEARCH and CYCLE clauses
On 1st of February 2021, Peter Eisentraut committed patch: SEARCH and CYCLE clauses This adds the SQL standard feature that adds the SEARCH and CYCLE clauses to recursive queries to be able to do produce breadth- or depth-first search orders and detect cycles. These clauses can be rewritten into queries using existing syntax, and that is what this patch does in the rewriter.
What's more – I didn't even had to add any condition on the is_cycle, it was sufficient that it's calculated, and processing stopped. And I can still add “WHERE is_cycle = false" to weed out the connections that cycle back to city that was already visited: All in all – both these things look amazing, and will greatly help writing queries for hierarchical data.
Or read this on Hacker News