Skip to content

Commit 17c8274

Browse files
committed
api: fix multiple-bound-locations by separating lifetimes; rt-async-std: drop unused imports; pg options: adjust AsRef where needed
1 parent cbfe331 commit 17c8274

File tree

8 files changed

+77
-53
lines changed

8 files changed

+77
-53
lines changed

sqlx-core/src/any/connection/executor.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ use futures_util::{StreamExt, TryStreamExt};
1414
impl<'c> Executor<'c> for &'c mut AnyConnection {
1515
type Database = Any;
1616

17-
fn fetch_many<'e, 'q: 'e, E: 'q>(
17+
fn fetch_many<'e, 'q, E>(
1818
self,
1919
mut query: E,
2020
) -> BoxStream<'e, Result<Either<AnyQueryResult, AnyRow>, Error>>
2121
where
2222
'c: 'e,
23+
'q: 'e,
2324
E: Execute<'q, Self::Database>,
2425
{
2526
let arguments = query.take_arguments();
@@ -52,12 +53,10 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
5253
}
5354
}
5455

55-
fn fetch_optional<'e, 'q: 'e, E: 'q>(
56-
self,
57-
mut query: E,
58-
) -> BoxFuture<'e, Result<Option<AnyRow>, Error>>
56+
fn fetch_optional<'e, 'q, E>(self, mut query: E) -> BoxFuture<'e, Result<Option<AnyRow>, Error>>
5957
where
6058
'c: 'e,
59+
'q: 'e,
6160
E: Execute<'q, Self::Database>,
6261
{
6362
let arguments = query.take_arguments();
@@ -92,13 +91,14 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
9291
})
9392
}
9493

95-
fn prepare_with<'e, 'q: 'e>(
94+
fn prepare_with<'e, 'q>(
9695
self,
9796
sql: &'q str,
9897
_parameters: &[AnyTypeInfo],
9998
) -> BoxFuture<'e, Result<AnyStatement<'q>, Error>>
10099
where
101100
'c: 'e,
101+
'q: 'e,
102102
{
103103
Box::pin(async move {
104104
Ok(match &mut self.0 {
@@ -118,12 +118,13 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
118118
})
119119
}
120120

121-
fn describe<'e, 'q: 'e>(
121+
fn describe<'e, 'q>(
122122
self,
123123
sql: &'q str,
124124
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
125125
where
126126
'c: 'e,
127+
'q: 'e,
127128
{
128129
Box::pin(async move {
129130
Ok(match &mut self.0 {

sqlx-core/src/executor.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ pub trait Executor<'c>: Send + Debug + Sized {
2626
type Database: Database;
2727

2828
/// Execute the query and return the total number of rows affected.
29-
fn execute<'e, 'q: 'e, E: 'q>(
29+
fn execute<'e, 'q, E>(
3030
self,
3131
query: E,
3232
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
3333
where
3434
'c: 'e,
35+
'q: 'e,
3536
E: Execute<'q, Self::Database>,
3637
{
3738
self.execute_many(query).try_collect().boxed()
3839
}
3940

4041
/// Execute multiple queries and return the rows affected from each query, in a stream.
41-
fn execute_many<'e, 'q: 'e, E: 'q>(
42+
fn execute_many<'e, 'q, E>(
4243
self,
4344
query: E,
4445
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
4546
where
4647
'c: 'e,
48+
'q: 'e,
4749
E: Execute<'q, Self::Database>,
4850
{
4951
self.fetch_many(query)
@@ -57,12 +59,13 @@ pub trait Executor<'c>: Send + Debug + Sized {
5759
}
5860

5961
/// Execute the query and return the generated results as a stream.
60-
fn fetch<'e, 'q: 'e, E: 'q>(
62+
fn fetch<'e, 'q, E>(
6163
self,
6264
query: E,
6365
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
6466
where
6567
'c: 'e,
68+
'q: 'e,
6669
E: Execute<'q, Self::Database>,
6770
{
6871
self.fetch_many(query)
@@ -77,7 +80,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
7780

7881
/// Execute multiple queries and return the generated results as a stream
7982
/// from each query, in a stream.
80-
fn fetch_many<'e, 'q: 'e, E: 'q>(
83+
fn fetch_many<'e, 'q, E>(
8184
self,
8285
query: E,
8386
) -> BoxStream<
@@ -89,27 +92,30 @@ pub trait Executor<'c>: Send + Debug + Sized {
8992
>
9093
where
9194
'c: 'e,
95+
'q: 'e,
9296
E: Execute<'q, Self::Database>;
9397

9498
/// Execute the query and return all the generated results, collected into a [`Vec`].
95-
fn fetch_all<'e, 'q: 'e, E: 'q>(
99+
fn fetch_all<'e, 'q, E>(
96100
self,
97101
query: E,
98102
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
99103
where
100104
'c: 'e,
105+
'q: 'e,
101106
E: Execute<'q, Self::Database>,
102107
{
103108
self.fetch(query).try_collect().boxed()
104109
}
105110

106111
/// Execute the query and returns exactly one row.
107-
fn fetch_one<'e, 'q: 'e, E: 'q>(
112+
fn fetch_one<'e, 'q, E>(
108113
self,
109114
query: E,
110115
) -> BoxFuture<'e, Result<<Self::Database as Database>::Row, Error>>
111116
where
112117
'c: 'e,
118+
'q: 'e,
113119
E: Execute<'q, Self::Database>,
114120
{
115121
self.fetch_optional(query)
@@ -121,12 +127,13 @@ pub trait Executor<'c>: Send + Debug + Sized {
121127
}
122128

123129
/// Execute the query and returns at most one row.
124-
fn fetch_optional<'e, 'q: 'e, E: 'q>(
130+
fn fetch_optional<'e, 'q, E>(
125131
self,
126132
query: E,
127133
) -> BoxFuture<'e, Result<Option<<Self::Database as Database>::Row>, Error>>
128134
where
129135
'c: 'e,
136+
'q: 'e,
130137
E: Execute<'q, Self::Database>;
131138

132139
/// Prepare the SQL query to inspect the type information of its parameters
@@ -138,12 +145,13 @@ pub trait Executor<'c>: Send + Debug + Sized {
138145
/// This explicit API is provided to allow access to the statement metadata available after
139146
/// it prepared but before the first row is returned.
140147
#[inline]
141-
fn prepare<'e, 'q: 'e>(
148+
fn prepare<'e, 'q>(
142149
self,
143150
query: &'q str,
144151
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>
145152
where
146153
'c: 'e,
154+
'q: 'e,
147155
{
148156
self.prepare_with(query, &[])
149157
}
@@ -153,26 +161,28 @@ pub trait Executor<'c>: Send + Debug + Sized {
153161
///
154162
/// Only some database drivers (PostgreSQL, MSSQL) can take advantage of
155163
/// this extra information to influence parameter type inference.
156-
fn prepare_with<'e, 'q: 'e>(
164+
fn prepare_with<'e, 'q>(
157165
self,
158166
sql: &'q str,
159167
parameters: &'e [<Self::Database as Database>::TypeInfo],
160168
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>
161169
where
162-
'c: 'e;
170+
'c: 'e,
171+
'q: 'e;
163172

164173
/// Describe the SQL query and return type information about its parameters
165174
/// and results.
166175
///
167176
/// This is used by compile-time verification in the query macros to
168177
/// power their type inference.
169178
#[doc(hidden)]
170-
fn describe<'e, 'q: 'e>(
179+
fn describe<'e, 'q>(
171180
self,
172181
sql: &'q str,
173182
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
174183
where
175-
'c: 'e;
184+
'c: 'e,
185+
'q: 'e;
176186
}
177187

178188
/// A type that may be executed against a database connection.

sqlx-core/src/mysql/connection/executor.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,13 @@ impl MySqlConnection {
213213
impl<'c> Executor<'c> for &'c mut MySqlConnection {
214214
type Database = MySql;
215215

216-
fn fetch_many<'e, 'q: 'e, E: 'q>(
216+
fn fetch_many<'e, 'q, E>(
217217
self,
218218
mut query: E,
219219
) -> BoxStream<'e, Result<Either<MySqlQueryResult, MySqlRow>, Error>>
220220
where
221221
'c: 'e,
222+
'q: 'e,
222223
E: Execute<'q, Self::Database>,
223224
{
224225
let sql = query.sql();
@@ -237,12 +238,10 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
237238
})
238239
}
239240

240-
fn fetch_optional<'e, 'q: 'e, E: 'q>(
241-
self,
242-
query: E,
243-
) -> BoxFuture<'e, Result<Option<MySqlRow>, Error>>
241+
fn fetch_optional<'e, 'q, E>(self, query: E) -> BoxFuture<'e, Result<Option<MySqlRow>, Error>>
244242
where
245243
'c: 'e,
244+
'q: 'e,
246245
E: Execute<'q, Self::Database>,
247246
{
248247
let mut s = self.fetch_many(query);
@@ -258,13 +257,14 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
258257
})
259258
}
260259

261-
fn prepare_with<'e, 'q: 'e>(
260+
fn prepare_with<'e, 'q>(
262261
self,
263262
sql: &'q str,
264263
_parameters: &'e [MySqlTypeInfo],
265264
) -> BoxFuture<'e, Result<MySqlStatement<'q>, Error>>
266265
where
267266
'c: 'e,
267+
'q: 'e,
268268
{
269269
Box::pin(async move {
270270
self.stream.wait_until_ready().await?;
@@ -280,9 +280,10 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
280280
}
281281

282282
#[doc(hidden)]
283-
fn describe<'e, 'q: 'e>(self, sql: &'q str) -> BoxFuture<'e, Result<Describe<MySql>, Error>>
283+
fn describe<'e, 'q>(self, sql: &'q str) -> BoxFuture<'e, Result<Describe<MySql>, Error>>
284284
where
285285
'c: 'e,
286+
'q: 'e,
286287
{
287288
Box::pin(async move {
288289
self.stream.wait_until_ready().await?;

sqlx-core/src/pool/executor.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ where
1515
{
1616
type Database = DB;
1717

18-
fn fetch_many<'e, 'q: 'e, E: 'q>(
18+
fn fetch_many<'e, 'q, E>(
1919
self,
2020
query: E,
2121
) -> BoxStream<'e, Result<Either<DB::QueryResult, DB::Row>, Error>>
2222
where
23+
'q: 'e,
2324
E: Execute<'q, Self::Database>,
2425
{
2526
let pool = self.clone();
@@ -36,11 +37,9 @@ where
3637
})
3738
}
3839

39-
fn fetch_optional<'e, 'q: 'e, E: 'q>(
40-
self,
41-
query: E,
42-
) -> BoxFuture<'e, Result<Option<DB::Row>, Error>>
40+
fn fetch_optional<'e, 'q, E>(self, query: E) -> BoxFuture<'e, Result<Option<DB::Row>, Error>>
4341
where
42+
'q: 'e,
4443
E: Execute<'q, Self::Database>,
4544
{
4645
let pool = self.clone();
@@ -77,7 +76,7 @@ macro_rules! impl_executor_for_pool_connection {
7776
type Database = $DB;
7877

7978
#[inline]
80-
fn fetch_many<'e, 'q: 'e, E: 'q>(
79+
fn fetch_many<'e, 'q, E>(
8180
self,
8281
query: E,
8382
) -> futures_core::stream::BoxStream<
@@ -89,25 +88,27 @@ macro_rules! impl_executor_for_pool_connection {
8988
>
9089
where
9190
'c: 'e,
91+
'q: 'e,
9292
E: crate::executor::Execute<'q, $DB>,
9393
{
9494
(**self).fetch_many(query)
9595
}
9696

9797
#[inline]
98-
fn fetch_optional<'e, 'q: 'e, E: 'q>(
98+
fn fetch_optional<'e, 'q, E>(
9999
self,
100100
query: E,
101101
) -> futures_core::future::BoxFuture<'e, Result<Option<$R>, crate::error::Error>>
102102
where
103103
'c: 'e,
104+
'q: 'e,
104105
E: crate::executor::Execute<'q, $DB>,
105106
{
106107
(**self).fetch_optional(query)
107108
}
108109

109110
#[inline]
110-
fn prepare_with<'e, 'q: 'e>(
111+
fn prepare_with<'e, 'q>(
111112
self,
112113
sql: &'q str,
113114
parameters: &'e [<$DB as crate::database::Database>::TypeInfo],
@@ -117,13 +118,14 @@ macro_rules! impl_executor_for_pool_connection {
117118
>
118119
where
119120
'c: 'e,
121+
'q: 'e,
120122
{
121123
(**self).prepare_with(sql, parameters)
122124
}
123125

124126
#[doc(hidden)]
125127
#[inline]
126-
fn describe<'e, 'q: 'e>(
128+
fn describe<'e, 'q>(
127129
self,
128130
sql: &'q str,
129131
) -> futures_core::future::BoxFuture<
@@ -132,6 +134,7 @@ macro_rules! impl_executor_for_pool_connection {
132134
>
133135
where
134136
'c: 'e,
137+
'q: 'e,
135138
{
136139
(**self).describe(sql)
137140
}

0 commit comments

Comments
 (0)