Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for array-like filter terms #1524

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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