Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Aug 6, 2024
1 parent c1032eb commit 6717a76
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
10 changes: 5 additions & 5 deletions src/builder_context/filter_types_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,35 +522,35 @@ 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()));
condition = condition.add(column.contains(value.to_string()));
}
}
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()));
condition = condition.add(column.starts_with(value.to_string()));
}
}
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()));
condition = condition.add(column.ends_with(value.to_string()));
}
}
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()));
condition = condition.add(column.like(value.to_string()));
}
}
FilterOperation::NotLike => {
if let Some(value) = filter.get("not_like") {
let value = types_map_helper
.async_graphql_value_to_sea_orm_value::<T>(column, &value)?;
condition = condition.add(column.not_like(&value.to_string()));
condition = condition.add(column.not_like(value.to_string()));
}
}
FilterOperation::Between => {
Expand Down
52 changes: 26 additions & 26 deletions src/builder_context/types_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ impl TypesMapHelper {
ConvertedType::Array(Box::new(inner))
}

#[cfg(not(feature = "with-ipnetwork"))]
// #[cfg(not(feature = "with-ipnetwork"))]
ColumnType::Cidr | ColumnType::Inet => ConvertedType::String,
#[cfg(feature = "with-ipnetwork")]
ColumnType::Cidr | ColumnType::Inet => ConvertedType::IpNetwork,
// #[cfg(feature = "with-ipnetwork")]
// ColumnType::Cidr | ColumnType::Inet => ConvertedType::IpNetwork,

#[cfg(not(feature = "with-mac_address"))]
// #[cfg(not(feature = "with-mac_address"))]
ColumnType::MacAddr => ConvertedType::String,
#[cfg(feature = "with-mac_address")]
ColumnType::MacAddr => ConvertedType::MacAddress,
// #[cfg(feature = "with-mac_address")]
// ColumnType::MacAddr => ConvertedType::MacAddress,
_ => panic!(
"Type mapping is not implemented for '{}.{}'",
entity_name, column_name
Expand Down Expand Up @@ -410,12 +410,12 @@ pub enum ConvertedType {
#[cfg(feature = "with-postgres-array")]
#[cfg_attr(docsrs, doc(cfg(feature = "with-postgres-array")))]
Array(Box<ConvertedType>),
#[cfg(feature = "with-ipnetwork")]
#[cfg_attr(docsrs, doc(cfg(feature = "with-ipnetwork")))]
IpNetwork,
#[cfg(feature = "with-mac_address")]
#[cfg_attr(docsrs, doc(cfg(feature = "with-mac_address")))]
MacAddress,
// #[cfg(feature = "with-ipnetwork")]
// #[cfg_attr(docsrs, doc(cfg(feature = "with-ipnetwork")))]
// IpNetwork,
// #[cfg(feature = "with-mac_address")]
// #[cfg_attr(docsrs, doc(cfg(feature = "with-mac_address")))]
// MacAddress,
Enum(String),
Custom(String),
}
Expand Down Expand Up @@ -472,10 +472,10 @@ pub fn converted_type_to_sea_orm_array_type(
ConvertedType::Decimal => Ok(sea_orm::sea_query::value::ArrayType::String),
#[cfg(feature = "with-bigdecimal")]
ConvertedType::BigDecimal => Ok(sea_orm::sea_query::value::ArrayType::String),
#[cfg(feature = "with-ipnetwork")]
ConvertedType::IpNetwork => Ok(sea_orm::sea_query::value::ArrayType::String),
#[cfg(feature = "with-mac_address")]
ConvertedType::MacAddress => Ok(sea_orm::sea_query::value::ArrayType::String),
// #[cfg(feature = "with-ipnetwork")]
// ConvertedType::IpNetwork => Ok(sea_orm::sea_query::value::ArrayType::String),
// #[cfg(feature = "with-mac_address")]
// ConvertedType::MacAddress => Ok(sea_orm::sea_query::value::ArrayType::String),
}
}

Expand Down Expand Up @@ -768,17 +768,17 @@ pub fn converted_value_to_sea_orm_value(
)
}
// FIXME: support ip type
#[cfg(feature = "with-ipnetwork")]
ConvertedType::IpNetwork => {
let value = value.string()?;
sea_orm::Value::String(Some(Box::new(value.to_string())))
}
// #[cfg(feature = "with-ipnetwork")]
// ConvertedType::IpNetwork => {
// let value = value.string()?;
// sea_orm::Value::String(Some(Box::new(value.to_string())))
// }
// FIXME: support mac type
#[cfg(feature = "with-mac_address")]
ConvertedType::MacAddress => {
let value = value.string()?;
sea_orm::Value::String(Some(Box::new(value.to_string())))
}
// #[cfg(feature = "with-mac_address")]
// ConvertedType::MacAddress => {
// let value = value.string()?;
// sea_orm::Value::String(Some(Box::new(value.to_string())))
// }
})
}

Expand Down
12 changes: 6 additions & 6 deletions src/outputs/entity_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ fn sea_query_value_to_graphql_value(
#[cfg_attr(docsrs, doc(cfg(feature = "with-bigdecimal")))]
sea_orm::sea_query::Value::BigDecimal(value) => value.map(|it| Value::from(it.to_string())),

#[cfg(feature = "with-ipnetwork")]
#[cfg_attr(docsrs, doc(cfg(feature = "with-ipnetwork")))]
sea_orm::sea_query::Value::IpNetwork(value) => value.map(|it| Value::from(it.to_string())),
// #[cfg(feature = "with-ipnetwork")]
// #[cfg_attr(docsrs, doc(cfg(feature = "with-ipnetwork")))]
// sea_orm::sea_query::Value::IpNetwork(value) => value.map(|it| Value::from(it.to_string())),

#[cfg(feature = "with-mac_address")]
#[cfg_attr(docsrs, doc(cfg(feature = "with-mac_address")))]
sea_orm::sea_query::Value::MacAddress(value) => value.map(|it| Value::from(it.to_string())),
// #[cfg(feature = "with-mac_address")]
// #[cfg_attr(docsrs, doc(cfg(feature = "with-mac_address")))]
// sea_orm::sea_query::Value::MacAddress(value) => value.map(|it| Value::from(it.to_string())),

#[allow(unreachable_patterns)]
_ => panic!("Cannot convert SeaORM value"),
Expand Down

0 comments on commit 6717a76

Please sign in to comment.