Skip to content

Commit

Permalink
fix: make sort order deterministic (metaplex-foundation#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsintunan authored Jun 29, 2023
1 parent bebefec commit 550874c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions digital_asset_types/src/dao/scopes/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,11 @@ where
let mut stmt = asset::Entity::find()
.filter(condition)
.join(JoinType::LeftJoin, relation.def())
.order_by(sort_by, sort_direction);
.order_by(sort_by, sort_direction)
.order_by(asset::Column::Id, Order::Asc);

stmt = paginate(pagination, limit, stmt);

let assets = stmt.all(conn).await?;

get_related_for_assets(conn, assets).await
}

Expand Down Expand Up @@ -252,11 +251,14 @@ pub async fn get_assets_by_condition(
for def in joins {
stmt = stmt.join(JoinType::LeftJoin, def);
}
stmt = stmt.filter(condition).order_by(sort_by, sort_direction);
stmt = stmt
.filter(condition)
.order_by(sort_by, sort_direction)
.order_by(asset::Column::Id, Order::Asc);

stmt = paginate(pagination, limit, stmt);
let asset_list = stmt.all(conn).await?;
get_related_for_assets(conn, asset_list).await
let assets = stmt.all(conn).await?;
get_related_for_assets(conn, assets).await
}

pub async fn get_by_id(
Expand Down

0 comments on commit 550874c

Please sign in to comment.