Skip to main content

topo_sort

Function topo_sort 

Source
pub fn topo_sort(
    tables: &[String],
    fks: &[ForeignKey],
) -> Result<Vec<String>, CycleError>
Expand description

Topologically sort tables so parents are loaded before children, using fks as the edge set. Tables referenced as parents but not present in tables (e.g. excluded from --all-tables selection) are dropped from the dependency graph.

Returns the load order on success, or CycleError when the remaining graph after Kahn’s algorithm still has nodes (i.e. every remaining node sits on a cycle).

The output preserves the relative order of independent tables from tables so successive runs against the same fixture produce identical orderings.