Trait rocket_db_pools::diesel::prelude::_
source · pub trait _ {
// Provided methods
fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>,
T: SqlType + TypedExpressionType { ... }
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType { ... }
}
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§
sourcefn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
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)
.
sourcefn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert &self
to an expression for Diesel’s query builder.
There is no difference in behavior between x.as_sql::<Y>()
and
AsExpression::<Y>::as_expression(&x)
.
Object Safety§
This trait is not object safe.