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 as Executor<'e>>::Database as Database>::QueryResult, Error>where
'q: 'e,
E: Executor<'e>,
pub async fn execute<'e, E>(
self,
executor: E
) -> Result<<<E as Executor<'e>>::Database as Database>::QueryResult, Error>where
'q: 'e,
E: Executor<'e>,
Execute the SQL string and return the total number of rows affected.
sourcepub fn execute_many<'e, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<<E as Executor<'e>>::Database as Database>::QueryResult, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'e>,
pub fn execute_many<'e, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<<E as Executor<'e>>::Database as Database>::QueryResult, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'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
) -> Pin<Box<dyn Stream<Item = Result<<<E as Executor<'e>>::Database as Database>::Row, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'e>,
pub fn fetch<'e, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<<E as Executor<'e>>::Database as Database>::Row, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'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
) -> Pin<Box<dyn Stream<Item = Result<Either<<<E as Executor<'e>>::Database as Database>::QueryResult, <<E as Executor<'e>>::Database as Database>::Row>, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'e>,
pub fn fetch_many<'e, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<<E as Executor<'e>>::Database as Database>::QueryResult, <<E as Executor<'e>>::Database as Database>::Row>, Error>> + Send + 'e>>where
'q: 'e,
E: Executor<'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 as Executor<'e>>::Database as Database>::Row>, Error>where
'q: 'e,
E: Executor<'e>,
pub async fn fetch_all<'e, E>(
self,
executor: E
) -> Result<Vec<<<E as Executor<'e>>::Database as Database>::Row>, Error>where
'q: 'e,
E: Executor<'e>,
sourcepub async fn fetch_one<'e, E>(
self,
executor: E
) -> Result<<<E as Executor<'e>>::Database as Database>::Row, Error>where
'q: 'e,
E: Executor<'e>,
pub async fn fetch_one<'e, E>(
self,
executor: E
) -> Result<<<E as Executor<'e>>::Database as Database>::Row, Error>where
'q: 'e,
E: Executor<'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 as Executor<'e>>::Database as Database>::Row, Error>where
'q: 'e,
E: Executor<'e>,
pub async fn fetch_optional<'e, E>(
self,
executor: E
) -> Result<<<E as Executor<'e>>::Database as Database>::Row, Error>where
'q: 'e,
E: Executor<'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> Execute<'q, DB> for RawSql<'q>where
DB: Database,
impl<'q, DB> Execute<'q, DB> for RawSql<'q>where
DB: Database,
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.