[][src]Struct diesel::query_builder::SqlQuery

#[must_use = "Queries are only executed when calling `load`, `get_result` or similar."]
pub struct SqlQuery<Inner = ()> { /* fields omitted */ }

The return value of sql_query.

Unlike most queries in Diesel, SqlQuery loads its data by column name, rather than by index. This means that you cannot deserialize this query into a tuple, and any structs used must implement QueryableByName.

See sql_query for examples.


impl<Inner> SqlQuery<Inner>[src]

pub fn bind<ST, Value>(self, value: Value) -> UncheckedBind<Self, Value, ST>[src]

Bind a value for use with this SQL query.


This function should be used with care, as Diesel cannot validate that the value is of the right type nor can it validate that you have passed the correct number of parameters.


let users = sql_query("SELECT * FROM users WHERE id > ? AND name <> ?")
    .bind::<Integer, _>(1)
    .bind::<Text, _>("Tess")
let expected_users = vec![
    User { id: 3, name: "Jim".into() },
assert_eq!(Ok(expected_users), users);

pub fn into_boxed<'f, DB: Backend>(self) -> BoxedSqlQuery<'f, DB, Self>[src]

Internally boxes future calls on bind and sql so that they don't change the type.

This allows doing things you otherwise couldn't do, e.g. binding in a loop.

pub fn sql<T: AsRef<str>>(self, sql: T) -> Self[src]

Appends a piece of SQL code at the end.

Trait Implementations

impl<Inner> QueryId for SqlQuery<Inner>[src]

type QueryId = ()

A type which uniquely represents Self in a SQL query. Read more

impl<DB, Inner> QueryFragment<DB> for SqlQuery<Inner> where
    DB: Backend,
    Inner: QueryFragment<DB>, 

impl<Inner, Conn, T> LoadQuery<Conn, T> for SqlQuery<Inner> where
    Conn: Connection,
    T: QueryableByName<Conn::Backend>,
    Self: QueryFragment<Conn::Backend>, 

impl<Inner, Conn> RunQueryDsl<Conn> for SqlQuery<Inner>[src]

impl<Inner: Clone> Clone for SqlQuery<Inner>[src]

impl<Inner: Debug> Debug for SqlQuery<Inner>[src]

Auto Trait Implementations

impl<Inner> Send for SqlQuery<Inner> where
    Inner: Send

impl<Inner> Sync for SqlQuery<Inner> where
    Inner: Sync

impl<Inner> Unpin for SqlQuery<Inner> where
    Inner: Unpin

impl<Inner> UnwindSafe for SqlQuery<Inner> where
    Inner: UnwindSafe

impl<Inner> RefUnwindSafe for SqlQuery<Inner> where
    Inner: RefUnwindSafe

Blanket Implementations

impl<T> IntoSql for T[src]

impl<Conn, T, U> LoadQuery<Conn, U> for T where
    Conn: Connection,
    T: AsQuery + RunQueryDsl<Conn>,
    U: Queryable<<T as AsQuery>::SqlType, <Conn as Connection>::Backend>,
    <Conn as Connection>::Backend: HasSqlType<<T as AsQuery>::SqlType>,
    <T as AsQuery>::Query: QueryFragment<<Conn as Connection>::Backend>,
    <T as AsQuery>::Query: QueryId

impl<Conn, DB, T> ExecuteDsl<Conn, DB> for T where
    Conn: Connection<Backend = DB>,
    DB: Backend,
    T: QueryFragment<DB> + QueryId

impl<T, Conn> RunQueryDsl<Conn> for T where
    T: Table

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized