Skip to content

Commit

Permalink
Ensure order of json keys to facilitate testing
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Crossley <[email protected]>
  • Loading branch information
jcrossley3 committed Dec 6, 2024
1 parent 07f2c2c commit bebb706
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/src/db/query/columns.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};

use sea_orm::entity::ColumnDef;
Expand All @@ -13,7 +13,7 @@ use super::Error;
pub struct Columns {
columns: Vec<(ColumnRef, ColumnDef)>,
translator: Option<Translator>,
json_keys: HashMap<&'static str, &'static str>,
json_keys: BTreeMap<&'static str, &'static str>,
}

impl Display for Columns {
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Columns {
Self {
columns,
translator: None,
json_keys: HashMap::new(),
json_keys: BTreeMap::new(),
}
}

Expand Down Expand Up @@ -365,7 +365,7 @@ mod tests {
);
assert_eq!(
clause(q("foo"))?,
r#"("advisory"."location" ILIKE '%foo%') OR ("advisory"."title" ILIKE '%foo%') OR (("purl" ->> 'type') ILIKE '%foo%') OR (("purl" ->> 'version') ILIKE '%foo%') OR (("purl" ->> 'name') ILIKE '%foo%')"#
r#"("advisory"."location" ILIKE '%foo%') OR ("advisory"."title" ILIKE '%foo%') OR (("purl" ->> 'name') ILIKE '%foo%') OR (("purl" ->> 'type') ILIKE '%foo%') OR (("purl" ->> 'version') ILIKE '%foo%')"#
);
assert!(clause(q("missing=gone")).is_err());
assert!(clause(q("").sort("name")).is_ok());
Expand Down

0 comments on commit bebb706

Please sign in to comment.