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

#[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. The given query should have placeholders that vary based on the database type, like SQLite Parameter syntax, PostgreSQL PREPARE syntax, or MySQL bind syntax.


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: Clone> Clone for SqlQuery<Inner>[src]

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

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

type SqlType = Untyped

The SQL type that this query represents. Read more

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

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

type QueryId = ()

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

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

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T> AsQuery for T where
    T: Query

type SqlType = <T as Query>::SqlType

The SQL type of Self::Query

type Query = T

What kind of query does this type represent?

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

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

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

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

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

impl<T> IntoSql 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<V, T> VZip<V> for T where
    V: MultiLane<T>,