Skip to content

Commit a862ba9

Browse files
authored
Pretty print: sort hashmap iters (#3188)
# Description of Changes Iterating over a HashMap does not guarantee any ordering of the items. To ensure consistent and predictable pretty-printing, explicitly sort entries. # API and ABI breaking changes NA # Expected complexity level and risk 0
1 parent ab23399 commit a862ba9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/schema/src/auto_migrate/formatter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
def::{ConstraintData, ModuleDef, ScheduleDef},
99
identifier::Identifier,
1010
};
11+
use itertools::Itertools;
1112
use spacetimedb_lib::{
1213
db::raw_def::v9::{RawRowLevelSecurityDefV9, TableAccess, TableType},
1314
AlgebraicType, AlgebraicValue,
@@ -247,6 +248,7 @@ fn extract_table_info(
247248
let constraints = table_def
248249
.constraints
249250
.values()
251+
.sorted_by_key(|c| c.name.clone())
250252
.map(|constraint| {
251253
let ConstraintData::Unique(unique) = &constraint.data;
252254
Ok(ConstraintInfo {
@@ -267,6 +269,7 @@ fn extract_table_info(
267269
let indexes = table_def
268270
.indexes
269271
.values()
272+
.sorted_by_key(|c| c.name.clone())
270273
.map(|index| {
271274
let columns = match &index.algorithm {
272275
IndexAlgorithm::BTree(btree) => btree
@@ -296,6 +299,7 @@ fn extract_table_info(
296299
let sequences = table_def
297300
.sequences
298301
.values()
302+
.sorted_by_key(|c| c.name.clone())
299303
.map(|sequence| {
300304
let column = table_def
301305
.get_column(sequence.column)

0 commit comments

Comments
 (0)