Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleyh committed Aug 18, 2024
1 parent 6acb241 commit 2f2728f
Showing 1 changed file with 30 additions and 57 deletions.
87 changes: 30 additions & 57 deletions src/lib/filtering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,24 +552,15 @@ impl Filtering {
FilterColumn::String(c, v) => Ok(Filtering::sql_str_i(cs, c, "LIKE", v)),

// try to convert the value to a valid type for the operator
FilterColumn::Int(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}%'", v.to_string()),
)),
FilterColumn::Float(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}%'", v.to_string()),
)),
FilterColumn::Bool(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}%'", v.to_string()),
)),
FilterColumn::Int(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}%'", v)))
}
FilterColumn::Float(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}%'", v)))
}
FilterColumn::Bool(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}%'", v)))
}

_ => Err(eyre::eyre!(
"Invalid column type '{}' for filter operator Like",
Expand All @@ -584,19 +575,19 @@ impl Filtering {
cs,
c,
"NOT LIKE",
format!("'%{}%'", v.to_string()),
format!("'%{}%'", v),
)),
FilterColumn::Float(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"NOT LIKE",
format!("'%{}%'", v.to_string()),
format!("'%{}%'", v),
)),
FilterColumn::Bool(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"NOT LIKE",
format!("'%{}%'", v.to_string()),
format!("'%{}%'", v),
)),

_ => Err(eyre::eyre!(
Expand Down Expand Up @@ -648,24 +639,15 @@ impl Filtering {
FilterColumn::String(c, v) => Ok(Filtering::sql_str_i(cs, c, "LIKE", v)),

// try to convert the value to a valid type for the operator
FilterColumn::Int(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'{}%'", v.to_string()),
)),
FilterColumn::Float(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'{}%'", v.to_string()),
)),
FilterColumn::Bool(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'{}%'", v.to_string()),
)),
FilterColumn::Int(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'{}%'", v)))
}
FilterColumn::Float(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'{}%'", v)))
}
FilterColumn::Bool(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'{}%'", v)))
}

_ => Err(eyre::eyre!(
"Invalid column type '{}' for filter operator Like",
Expand All @@ -676,24 +658,15 @@ impl Filtering {
FilterColumn::String(c, v) => Ok(Filtering::sql_str_i(cs, c, "LIKE", v)),

// try to convert the value to a valid type for the operator
FilterColumn::Int(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}'", v.to_string()),
)),
FilterColumn::Float(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}'", v.to_string()),
)),
FilterColumn::Bool(c, v) => Ok(Filtering::sql_str_i(
cs,
c,
"LIKE",
format!("'%{}'", v.to_string()),
)),
FilterColumn::Int(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}'", v)))
}
FilterColumn::Float(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}'", v)))
}
FilterColumn::Bool(c, v) => {
Ok(Filtering::sql_str_i(cs, c, "LIKE", format!("'%{}'", v)))
}

_ => Err(eyre::eyre!(
"Invalid column type '{}' for filter operator Like",
Expand Down

0 comments on commit 2f2728f

Please sign in to comment.