Skip to content

Commit

Permalink
fix(store): Order data sources by vid (#3854)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens authored Aug 22, 2022
1 parent 0d35ff1 commit 784fbfa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions store/postgres/src/dynds/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) struct DataSourcesTable {
namespace: Namespace,
qname: String,
table: DynTable,
vid: DynColumn<Integer>,
block_range: DynColumn<sql_types::Range<Integer>>,
_causality_region: DynColumn<Integer>,
manifest_idx: DynColumn<Integer>,
Expand All @@ -40,6 +41,7 @@ impl DataSourcesTable {
DataSourcesTable {
qname: format!("{}.{}", namespace, Self::TABLE_NAME),
namespace,
vid: table.column("vid"),
block_range: table.column("block_range"),
_causality_region: table.column("causality_region"),
manifest_idx: table.column("manifest_idx"),
Expand Down Expand Up @@ -94,6 +96,7 @@ impl DataSourcesTable {
&self.param,
&self.context,
))
.order_by(&self.vid)
.load::<Tuple>(conn)?;

let mut dses: Vec<_> = tuples
Expand All @@ -113,6 +116,8 @@ impl DataSourcesTable {
}
})
.collect();

// This sort is stable and `tuples` was ordered by vid, so `dses` will be ordered by `(creation_block, vid)`.
dses.sort_by_key(|v| v.creation_block);

Ok(dses)
Expand Down

0 comments on commit 784fbfa

Please sign in to comment.