[][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.

Implementations

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.

Safety

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.

Example

let users = sql_query("SELECT * FROM users WHERE id > ? AND name <> ?")
    .bind::<Integer, _>(1)
    .bind::<Text, _>("Tess")
    .get_results(&connection);
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>, 
[src]

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
[src]

impl<T> AsQuery for T where
    T: Query
[src]

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
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoSql for T[src]

impl<Conn, T, U> LoadQuery<Conn, U> for T where
    Conn: Connection,
    T: AsQuery + RunQueryDsl<Conn>,
    U: FromSqlRow<<T as AsQuery>::SqlType, <Conn as Connection>::Backend>,
    <T as AsQuery>::Query: QueryFragment<<Conn as Connection>::Backend>,
    <T as AsQuery>::Query: QueryId,
    <Conn as Connection>::Backend: QueryMetadata<<T as AsQuery>::SqlType>, 
[src]

impl<T, Conn> RunQueryDsl<Conn> for T where
    T: Table
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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>, 
[src]