pub struct RawSql(/* private fields */);Expand description
One or more raw SQL statements, separated by semicolons (;).
See raw_sql() for details.
Implementations§
Source§impl RawSql
 
impl RawSql
Sourcepub async fn execute<'e, E, DB>(self, executor: E) -> Result<DB::QueryResult>
 
pub async fn execute<'e, E, DB>(self, executor: E) -> Result<DB::QueryResult>
Execute the SQL string and return the total number of rows affected.
Sourcepub fn execute_many<'e, E, DB>(
    self,
    executor: E,
) -> BoxStream<'e, Result<DB::QueryResult>>
 
pub fn execute_many<'e, E, DB>( self, executor: E, ) -> BoxStream<'e, Result<DB::QueryResult>>
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, DB>(
    self,
    executor: E,
) -> BoxStream<'e, Result<DB::Row, Error>>
 
pub fn fetch<'e, E, DB>( self, executor: E, ) -> BoxStream<'e, Result<DB::Row, Error>>
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, DB>(
    self,
    executor: E,
) -> BoxStream<'e, Result<Either<DB::QueryResult, DB::Row>, Error>>
 
pub fn fetch_many<'e, E, DB>( self, executor: E, ) -> BoxStream<'e, Result<Either<DB::QueryResult, DB::Row>, Error>>
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 fn fetch_one<'e, E, DB>(self, executor: E) -> BoxFuture<'e, Result<DB::Row>>
 
pub fn fetch_one<'e, E, DB>(self, executor: E) -> BoxFuture<'e, Result<DB::Row>>
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, DB>(
    self,
    executor: E,
) -> Result<Option<DB::Row>>
 
pub async fn fetch_optional<'e, E, DB>( self, executor: E, ) -> Result<Option<DB::Row>>
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<DB: Database> Execute<'_, DB> for RawSql
 
impl<DB: Database> Execute<'_, DB> for RawSql
Source§fn statement(&self) -> Option<&<DB as Database>::Statement>
 
fn statement(&self) -> Option<&<DB as Database>::Statement>
Source§fn take_arguments(
    &mut self,
) -> Result<Option<<DB as Database>::Arguments>, BoxDynError>
 
fn take_arguments( &mut self, ) -> Result<Option<<DB as Database>::Arguments>, BoxDynError>
Source§fn persistent(&self) -> bool
 
fn persistent(&self) -> bool
true if the statement should be cached.Auto Trait Implementations§
impl Freeze for RawSql
impl RefUnwindSafe for RawSql
impl Send for RawSql
impl Sync for RawSql
impl Unpin for RawSql
impl UnwindSafe for RawSql
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