pub struct RawSql<'q>(/* private fields */);
Expand description
One or more raw SQL statements, separated by semicolons (;
).
See raw_sql()
for details.
Implementations§
source§impl<'q> RawSql<'q>
impl<'q> RawSql<'q>
sourcepub async fn execute<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::QueryResult>where
E: Executor<'e>,
'q: 'e,
pub async fn execute<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::QueryResult>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string and return the total number of rows affected.
sourcepub fn execute_many<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<<E::Database as Database>::QueryResult>>where
E: Executor<'e>,
'q: 'e,
pub fn execute_many<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<<E::Database as Database>::QueryResult>>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string. Returns a stream which gives the number of rows affected for each statement in the string.
sourcepub fn fetch<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<<E::Database as Database>::Row, Error>>where
E: Executor<'e>,
'q: 'e,
pub fn fetch<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<<E::Database as Database>::Row, Error>>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string and return the generated results as a stream.
If the string contains multiple statements, their results will be concatenated together.
sourcepub fn fetch_many<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<Either<<E::Database as Database>::QueryResult, <E::Database as Database>::Row>, Error>>where
E: Executor<'e>,
'q: 'e,
pub fn fetch_many<'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<Either<<E::Database as Database>::QueryResult, <E::Database as Database>::Row>, Error>>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string and return the generated results as a stream.
For each query in the stream, any generated rows are returned first,
then the QueryResult
with the number of rows affected.
sourcepub async fn fetch_all<'e, E>(
self,
executor: E,
) -> Result<Vec<<E::Database as Database>::Row>>where
E: Executor<'e>,
'q: 'e,
pub async fn fetch_all<'e, E>(
self,
executor: E,
) -> Result<Vec<<E::Database as Database>::Row>>where
E: Executor<'e>,
'q: 'e,
sourcepub async fn fetch_one<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::Row>where
E: Executor<'e>,
'q: 'e,
pub async fn fetch_one<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::Row>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string, returning the first row or Error::RowNotFound
otherwise.
§Note: for best performance, ensure the query returns at most one row.
Depending on the driver implementation, if your query can return more than one row, it may lead to wasted CPU time and bandwidth on the database server.
Even when the driver implementation takes this into account, ensuring the query returns at most one row can result in a more optimal query plan.
If your query has a WHERE
clause filtering a unique column by a single value, you’re good.
Otherwise, you might want to add LIMIT 1
to your query.
sourcepub async fn fetch_optional<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::Row>where
E: Executor<'e>,
'q: 'e,
pub async fn fetch_optional<'e, E>(
self,
executor: E,
) -> Result<<E::Database as Database>::Row>where
E: Executor<'e>,
'q: 'e,
Execute the SQL string, returning the first row or None
otherwise.
§Note: for best performance, ensure the query returns at most one row.
Depending on the driver implementation, if your query can return more than one row, it may lead to wasted CPU time and bandwidth on the database server.
Even when the driver implementation takes this into account, ensuring the query returns at most one row can result in a more optimal query plan.
If your query has a WHERE
clause filtering a unique column by a single value, you’re good.
Otherwise, you might want to add LIMIT 1
to your query.
Trait Implementations§
source§impl<'q, DB: Database> Execute<'q, DB> for RawSql<'q>
impl<'q, DB: Database> Execute<'q, DB> for RawSql<'q>
source§fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>
fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>
source§fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>
fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>
source§fn persistent(&self) -> bool
fn persistent(&self) -> bool
true
if the statement should be cached.Auto Trait Implementations§
impl<'q> Freeze for RawSql<'q>
impl<'q> RefUnwindSafe for RawSql<'q>
impl<'q> Send for RawSql<'q>
impl<'q> Sync for RawSql<'q>
impl<'q> Unpin for RawSql<'q>
impl<'q> UnwindSafe for RawSql<'q>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more