Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up(mysql) LIKE for non-text columns #1802
Comments
This comment has been minimized.
|
See http://diesel.rs/guides/extending-diesel/#custom-operators for examples of how to add new operators to Diesel |
sgrif
closed this
Jul 30, 2018
This comment has been minimized.
RazrFalcon
commented
Jul 30, 2018
|
Thanks. I've tried this: diesel_infix_operator!(MyLike, " LIKE ");
pub trait MyLikeMethods: Expression + Sized {
fn my_like<T: AsExpression<Self::SqlType>>(self, rhs: T) -> MyLike<Self, T::Expression> {
MyLike::new(self, rhs.as_expression())
}
}
impl<T: Expression> MyLikeMethods for T {}
{
let some_text = "some text".to_string();
let list: Vec<MyStruct> = table::my_table
.filter(columns::my_table::price.my_like(format!("%{}%", some_text)))
.load(conn)?;
}But I'm getting:
The |
This comment has been minimized.
|
You defined |
This comment has been minimized.
RazrFalcon
commented
Jul 31, 2018
|
Thanks! It worked. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RazrFalcon commentedJul 30, 2018
I there a way to use LIKE statement for any column? Currently, it tied to
TextExpressionMethods. But MySQL works fine with any column type.PS: I need this to fuzzy search in
DECIMALcolumn.