Skip to content

Commit

Permalink
Fix support for array-like filter terms
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Aug 30, 2021
1 parent d65229c commit 86b3798
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions rust/perspective-vieux/src/rust/config/view_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub enum FilterOp {
#[serde(rename = "in")]
In,

#[serde(rename = "not in")]
NotIn,

#[serde(rename = "begins with")]
BeginsWith,

Expand Down Expand Up @@ -106,9 +109,17 @@ pub enum SortDir {
ColAscAbs,
}

#[derive(Clone, Deserialize, Debug, PartialEq, Serialize)]
#[serde(untagged)]
pub enum FilterTerm {
Scalar(Scalar),
Array(Vec<Scalar>),
}

#[derive(Clone, Deserialize, Debug, PartialEq, Serialize)]
#[serde()]
pub struct Filter(String, FilterOp, Scalar);
pub struct Filter(String, FilterOp, FilterTerm);


#[derive(Clone, Deserialize, Debug, PartialEq, Serialize)]
#[serde()]
Expand Down Expand Up @@ -379,7 +390,7 @@ mod tests {
vec!(Filter(
"Test".to_owned(),
FilterOp::Contains,
Scalar::String("aaa".to_owned())
FilterTerm::Scalar(Scalar::String("aaa".to_owned()))
))
);
}
Expand All @@ -396,7 +407,7 @@ mod tests {
vec!(Filter(
"Test".to_owned(),
FilterOp::LT,
Scalar::Float(4_f64)
FilterTerm::Scalar(Scalar::Float(4_f64))
))
);
}
Expand Down

0 comments on commit 86b3798

Please sign in to comment.