Trait diesel::expression::IntoSql [−][src]
pub trait IntoSql { fn into_sql<T>(self) -> AsExprOf<Self, T>
where
Self: AsExpression<T> + Sized, { ... } fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where
&'a Self: AsExpression<T>, { ... } }
Expand description
Converts a type to its representation for use in Diesel’s query builder.
This trait only exists to make usage of AsExpression
more ergonomic when
the SqlType
cannot be inferred. It is generally used when you need to use
a Rust value as the left hand side of an expression, or when you want to
select a constant value.
Example
use diesel::sql_types::Text; let names = users::table .select("The Amazing ".into_sql::<Text>().concat(users::name)) .load(&conn); let expected_names = vec![ "The Amazing Sean".to_string(), "The Amazing Tess".to_string(), ]; assert_eq!(Ok(expected_names), names);
Provided methods
fn into_sql<T>(self) -> AsExprOf<Self, T> where
Self: AsExpression<T> + Sized,
fn into_sql<T>(self) -> AsExprOf<Self, T> where
Self: AsExpression<T> + Sized,
Convert self
to an expression for Diesel’s query builder.
There is no difference in behavior between x.into_sql::<Y>()
and
AsExpression::<Y>::as_expression(x)
.