Skip to content

fix: executor arg of RawSql methods can have looser bound #3656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions sqlx-core/src/raw_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,26 @@ impl<'q, DB: Database> Execute<'q, DB> for RawSql<'q> {
impl<'q> RawSql<'q> {
/// Execute the SQL string and return the total number of rows affected.
#[inline]
pub async fn execute<'e, E>(
pub async fn execute<'e, 'c: 'e, E>(
self,
executor: E,
) -> crate::Result<<E::Database as Database>::QueryResult>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.execute(self).await
}

/// Execute the SQL string. Returns a stream which gives the number of rows affected for each statement in the string.
#[inline]
pub fn execute_many<'e, E>(
pub fn execute_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, crate::Result<<E::Database as Database>::QueryResult>>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.execute_many(self)
}
Expand All @@ -167,13 +167,13 @@ impl<'q> RawSql<'q> {
///
/// If the string contains multiple statements, their results will be concatenated together.
#[inline]
pub fn fetch<'e, E>(
pub fn fetch<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<<E::Database as Database>::Row, Error>>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.fetch(self)
}
Expand All @@ -183,7 +183,7 @@ impl<'q> RawSql<'q> {
/// For each query in the stream, any generated rows are returned first,
/// then the `QueryResult` with the number of rows affected.
#[inline]
pub fn fetch_many<'e, E>(
pub fn fetch_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<
Expand All @@ -195,7 +195,7 @@ impl<'q> RawSql<'q> {
>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.fetch_many(self)
}
Expand All @@ -208,7 +208,7 @@ impl<'q> RawSql<'q> {
/// To avoid exhausting available memory, ensure the result set has a known upper bound,
/// e.g. using `LIMIT`.
#[inline]
pub async fn fetch_all<'e, E>(
pub async fn fetch_all<'e, 'c: 'e, E>(
self,
executor: E,
) -> crate::Result<Vec<<E::Database as Database>::Row>>
Expand All @@ -232,13 +232,13 @@ impl<'q> RawSql<'q> {
///
/// Otherwise, you might want to add `LIMIT 1` to your query.
#[inline]
pub async fn fetch_one<'e, E>(
pub async fn fetch_one<'e, 'c: 'e, E>(
self,
executor: E,
) -> crate::Result<<E::Database as Database>::Row>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.fetch_one(self).await
}
Expand All @@ -256,13 +256,13 @@ impl<'q> RawSql<'q> {
///
/// Otherwise, you might want to add `LIMIT 1` to your query.
#[inline]
pub async fn fetch_optional<'e, E>(
pub async fn fetch_optional<'e, 'c: 'e, E>(
self,
executor: E,
) -> crate::Result<<E::Database as Database>::Row>
where
'q: 'e,
E: Executor<'e>,
E: Executor<'c>,
{
executor.fetch_one(self).await
}
Expand Down