Struct diesel::query_builder::SqlQuery
source · [−]pub struct SqlQuery<Inner = Empty> { /* private fields */ }
Expand description
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
sourceimpl<Inner> SqlQuery<Inner>
impl<Inner> SqlQuery<Inner>
sourcepub fn bind<ST, Value>(self, value: Value) -> UncheckedBind<Self, Value, ST>
pub fn bind<ST, Value>(self, value: Value) -> UncheckedBind<Self, Value, ST>
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);
sourcepub fn into_boxed<'f, DB: Backend>(self) -> BoxedSqlQuery<'f, DB, Self>
pub fn into_boxed<'f, DB: Backend>(self) -> BoxedSqlQuery<'f, DB, Self>
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. bind
ing in a
loop.
Trait Implementations
sourceimpl<Inner> QueryId for SqlQuery<Inner>
impl<Inner> QueryId for SqlQuery<Inner>
sourceconst HAS_STATIC_QUERY_ID: bool = false
const HAS_STATIC_QUERY_ID: bool = false
Self
be uniquely identified by its type? Read moresourceimpl<Inner, Conn> RunQueryDsl<Conn> for SqlQuery<Inner>
impl<Inner, Conn> RunQueryDsl<Conn> for SqlQuery<Inner>
sourcefn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>where
Self: LoadQuery<'query, Conn, U>,
fn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>where
Self: LoadQuery<'query, Conn, U>,
sourcefn load_iter<'conn, 'query: 'conn, U, B>(
self,
conn: &'conn mut Conn
) -> QueryResult<LoadIter<'conn, 'query, Self, Conn, U, B>>where
U: 'conn,
Self: LoadQuery<'query, Conn, U, B> + 'conn,
fn load_iter<'conn, 'query: 'conn, U, B>(
self,
conn: &'conn mut Conn
) -> QueryResult<LoadIter<'conn, 'query, Self, Conn, U, B>>where
U: 'conn,
Self: LoadQuery<'query, Conn, U, B> + 'conn,
sourcefn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>where
Self: LoadQuery<'query, Conn, U>,
fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>where
Self: LoadQuery<'query, Conn, U>,
sourcefn get_results<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>where
Self: LoadQuery<'query, Conn, U>,
fn get_results<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>where
Self: LoadQuery<'query, Conn, U>,
Vec
with the affected rows. Read moreAuto 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
sourceimpl<T> AsQuery for Twhere
T: Query,
impl<T> AsQuery for Twhere
T: Query,
type Query = T
type Query = T
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Conn, DB, T> ExecuteDsl<Conn, DB> for Twhere
Conn: Connection<Backend = DB>,
DB: Backend,
T: QueryFragment<DB, NotSpecialized> + QueryId,
impl<Conn, DB, T> ExecuteDsl<Conn, DB> for Twhere
Conn: Connection<Backend = DB>,
DB: Backend,
T: QueryFragment<DB, NotSpecialized> + QueryId,
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> AsExprOf<Self, T>where
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> AsExprOf<Self, T>where
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
self
to an expression for Diesel’s query builder. Read moresourcefn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
&self
to an expression for Diesel’s query builder. Read more