Trait block_tools::db::use_diesel::expression::IntoSql[][src]

pub trait IntoSql {
    pub fn into_sql<T>(self) -> Self::Expression
    where
        Self: AsExpression<T>
, { ... }
pub fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
    where
        &'a Self: AsExpression<T>
, { ... } }

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

pub fn into_sql<T>(self) -> Self::Expression where
    Self: AsExpression<T>, 
[src]

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).

pub fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
    &'a Self: AsExpression<T>, 
[src]

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).

Loading content...

Implementors

impl<T> IntoSql for T[src]

Loading content...