Skip to content

Commit

Permalink
Fix: LIKE wildcard operations (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 authored Oct 7, 2024
1 parent 1d74ad0 commit d84509c
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/builder_context/filter_types_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,28 +522,44 @@ impl FilterTypesMapHelper {
if let Some(value) = filter.get("contains") {
let value = types_map_helper
.async_graphql_value_to_sea_orm_value::<T>(column, &value)?;
condition = condition.add(column.contains(value.to_string()));
let s = match value {
sea_orm::sea_query::Value::String(Some(s)) => s.to_string(),
_ => value.to_string(),
};
condition = condition.add(column.contains(s));
}
}
FilterOperation::StartsWith => {
if let Some(value) = filter.get("starts_with") {
let value = types_map_helper
.async_graphql_value_to_sea_orm_value::<T>(column, &value)?;
condition = condition.add(column.starts_with(value.to_string()));
let s = match value {
sea_orm::sea_query::Value::String(Some(s)) => s.to_string(),
_ => value.to_string(),
};
condition = condition.add(column.starts_with(s));
}
}
FilterOperation::EndsWith => {
if let Some(value) = filter.get("ends_with") {
let value = types_map_helper
.async_graphql_value_to_sea_orm_value::<T>(column, &value)?;
condition = condition.add(column.ends_with(value.to_string()));
let s = match value {
sea_orm::sea_query::Value::String(Some(s)) => s.to_string(),
_ => value.to_string(),
};
condition = condition.add(column.ends_with(s));
}
}
FilterOperation::Like => {
if let Some(value) = filter.get("like") {
let value = types_map_helper
.async_graphql_value_to_sea_orm_value::<T>(column, &value)?;
condition = condition.add(column.like(value.to_string()));
let s = match value {
sea_orm::sea_query::Value::String(Some(s)) => s.to_string(),
_ => value.to_string(),
};
condition = condition.add(column.like(s));
}
}
FilterOperation::NotLike => {
Expand Down

0 comments on commit d84509c

Please sign in to comment.