Skip to content

Commit

Permalink
order columns when updating strategy.json (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
danturn authored Sep 30, 2022
1 parent 8934b4b commit bbe2126
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/parsers/strategy_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ fn add_missing(present: Vec<StrategyInFile>, missing: &[SimpleColumn]) -> Vec<St

new_strategies.sort();

for s in new_strategies.iter_mut() {
sort_columns(s)
}

new_strategies
}
fn sort_columns(s: &mut StrategyInFile) {
s.columns.sort_by(|a, b| a.name.cmp(&b.name))
}

fn remove_redundant(
existing: Vec<StrategyInFile>,
Expand Down Expand Up @@ -206,8 +213,8 @@ mod tests {
table_name: "public.person".to_string(),
description: "".to_string(),
columns: vec![
ColumnInFile::new("id"),
ColumnInFile::new("first_name"),
ColumnInFile::new("id"),
ColumnInFile::new("last_name"),
],
},
Expand Down

0 comments on commit bbe2126

Please sign in to comment.