Skip to content

Commit af52820

Browse files
committed
Update Executor trait
1 parent 4e09194 commit af52820

File tree

7 files changed

+23
-48
lines changed

7 files changed

+23
-48
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::any::{Any, AnyConnection, AnyQueryResult, AnyRow, AnyStatement, AnyTy
22
use crate::describe::Describe;
33
use crate::error::Error;
44
use crate::executor::{Execute, Executor};
5-
use crate::sql_str::SqlSafeStr;
5+
use crate::sql_str::SqlStr;
66
use either::Either;
77
use futures_core::future::BoxFuture;
88
use futures_core::stream::BoxStream;
@@ -47,22 +47,19 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
4747

4848
fn prepare_with<'e>(
4949
self,
50-
sql: impl SqlSafeStr,
50+
sql: SqlStr,
5151
parameters: &[AnyTypeInfo],
5252
) -> BoxFuture<'e, Result<AnyStatement, Error>>
5353
where
5454
'c: 'e,
5555
{
56-
self.backend.prepare_with(sql.into_sql_str(), parameters)
56+
self.backend.prepare_with(sql, parameters)
5757
}
5858

59-
fn describe<'e>(
60-
self,
61-
sql: impl SqlSafeStr,
62-
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
59+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
6360
where
6461
'c: 'e,
6562
{
66-
self.backend.describe(sql.into_sql_str())
63+
self.backend.describe(sql)
6764
}
6865
}

sqlx-core/src/executor.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
151151
#[inline]
152152
fn prepare<'e>(
153153
self,
154-
query: impl SqlSafeStr,
154+
query: SqlStr,
155155
) -> BoxFuture<'e, Result<<Self::Database as Database>::Statement, Error>>
156156
where
157157
'c: 'e,
@@ -166,7 +166,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
166166
/// this extra information to influence parameter type inference.
167167
fn prepare_with<'e>(
168168
self,
169-
sql: impl SqlSafeStr,
169+
sql: SqlStr,
170170
parameters: &'e [<Self::Database as Database>::TypeInfo],
171171
) -> BoxFuture<'e, Result<<Self::Database as Database>::Statement, Error>>
172172
where
@@ -178,10 +178,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
178178
/// This is used by compile-time verification in the query macros to
179179
/// power their type inference.
180180
#[doc(hidden)]
181-
fn describe<'e>(
182-
self,
183-
sql: impl SqlSafeStr,
184-
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
181+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
185182
where
186183
'c: 'e;
187184
}

sqlx-core/src/pool/executor.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::describe::Describe;
88
use crate::error::Error;
99
use crate::executor::{Execute, Executor};
1010
use crate::pool::Pool;
11-
use crate::sql_str::SqlSafeStr;
11+
use crate::sql_str::SqlStr;
1212

1313
impl<'p, DB: Database> Executor<'p> for &'_ Pool<DB>
1414
where
@@ -51,25 +51,20 @@ where
5151

5252
fn prepare_with<'e>(
5353
self,
54-
sql: impl SqlSafeStr,
54+
sql: SqlStr,
5555
parameters: &'e [<Self::Database as Database>::TypeInfo],
5656
) -> BoxFuture<'e, Result<<Self::Database as Database>::Statement, Error>>
5757
where
5858
'p: 'e,
5959
{
6060
let pool = self.clone();
61-
let sql = sql.into_sql_str();
6261

6362
Box::pin(async move { pool.acquire().await?.prepare_with(sql, parameters).await })
6463
}
6564

6665
#[doc(hidden)]
67-
fn describe<'e>(
68-
self,
69-
sql: impl SqlSafeStr,
70-
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>> {
66+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>> {
7167
let pool = self.clone();
72-
let sql = sql.into_sql_str();
7368

7469
Box::pin(async move { pool.acquire().await?.describe(sql).await })
7570
}

sqlx-mysql/src/connection/executor.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use futures_core::stream::BoxStream;
2323
use futures_core::Stream;
2424
use futures_util::TryStreamExt;
2525
use sqlx_core::column::{ColumnOrigin, TableColumn};
26-
use sqlx_core::sql_str::{SqlSafeStr, SqlStr};
26+
use sqlx_core::sql_str::SqlStr;
2727
use std::{pin::pin, sync::Arc};
2828

2929
impl MySqlConnection {
@@ -325,13 +325,12 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
325325

326326
fn prepare_with<'e>(
327327
self,
328-
sql: impl SqlSafeStr,
328+
sql: SqlStr,
329329
_parameters: &'e [MySqlTypeInfo],
330330
) -> BoxFuture<'e, Result<MySqlStatement, Error>>
331331
where
332332
'c: 'e,
333333
{
334-
let sql = sql.into_sql_str();
335334
Box::pin(async move {
336335
self.inner.stream.wait_until_ready().await?;
337336

@@ -357,11 +356,10 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
357356
}
358357

359358
#[doc(hidden)]
360-
fn describe<'e>(self, sql: impl SqlSafeStr) -> BoxFuture<'e, Result<Describe<MySql>, Error>>
359+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<MySql>, Error>>
361360
where
362361
'c: 'e,
363362
{
364-
let sql = sql.into_sql_str();
365363
Box::pin(async move {
366364
self.inner.stream.wait_until_ready().await?;
367365

sqlx-postgres/src/connection/executor.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use futures_core::stream::BoxStream;
1717
use futures_core::Stream;
1818
use futures_util::TryStreamExt;
1919
use sqlx_core::arguments::Arguments;
20-
use sqlx_core::sql_str::{SqlSafeStr, SqlStr};
20+
use sqlx_core::sql_str::SqlStr;
2121
use sqlx_core::Either;
2222
use std::{pin::pin, sync::Arc};
2323

@@ -462,13 +462,12 @@ impl<'c> Executor<'c> for &'c mut PgConnection {
462462

463463
fn prepare_with<'e>(
464464
self,
465-
sql: impl SqlSafeStr,
465+
sql: SqlStr,
466466
parameters: &'e [PgTypeInfo],
467467
) -> BoxFuture<'e, Result<PgStatement, Error>>
468468
where
469469
'c: 'e,
470470
{
471-
let sql = sql.into_sql_str();
472471
Box::pin(async move {
473472
self.wait_until_ready().await?;
474473

@@ -480,14 +479,10 @@ impl<'c> Executor<'c> for &'c mut PgConnection {
480479
})
481480
}
482481

483-
fn describe<'e>(
484-
self,
485-
sql: impl SqlSafeStr,
486-
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
482+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
487483
where
488484
'c: 'e,
489485
{
490-
let sql = sql.into_sql_str();
491486
Box::pin(async move {
492487
self.wait_until_ready().await?;
493488

sqlx-postgres/src/listener.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use futures_core::future::BoxFuture;
77
use futures_core::stream::{BoxStream, Stream};
88
use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt};
99
use sqlx_core::acquire::Acquire;
10-
use sqlx_core::sql_str::{AssertSqlSafe, SqlSafeStr};
10+
use sqlx_core::sql_str::{AssertSqlSafe, SqlStr};
1111
use sqlx_core::transaction::Transaction;
1212
use sqlx_core::Either;
1313
use tracing::Instrument;
@@ -423,13 +423,12 @@ impl<'c> Executor<'c> for &'c mut PgListener {
423423

424424
fn prepare_with<'e>(
425425
self,
426-
query: impl SqlSafeStr,
426+
query: SqlStr,
427427
parameters: &'e [PgTypeInfo],
428428
) -> BoxFuture<'e, Result<PgStatement, Error>>
429429
where
430430
'c: 'e,
431431
{
432-
let query = query.into_sql_str();
433432
async move {
434433
self.connection()
435434
.await?
@@ -440,14 +439,10 @@ impl<'c> Executor<'c> for &'c mut PgListener {
440439
}
441440

442441
#[doc(hidden)]
443-
fn describe<'e>(
444-
self,
445-
query: impl SqlSafeStr,
446-
) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
442+
fn describe<'e>(self, query: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
447443
where
448444
'c: 'e,
449445
{
450-
let query = query.into_sql_str();
451446
async move { self.connection().await?.describe(query).await }.boxed()
452447
}
453448
}

sqlx-sqlite/src/connection/executor.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use futures_util::{stream, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
77
use sqlx_core::describe::Describe;
88
use sqlx_core::error::Error;
99
use sqlx_core::executor::{Execute, Executor};
10-
use sqlx_core::sql_str::SqlSafeStr;
10+
use sqlx_core::sql_str::SqlStr;
1111
use sqlx_core::Either;
1212
use std::{future, pin::pin};
1313

@@ -75,13 +75,12 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
7575

7676
fn prepare_with<'e>(
7777
self,
78-
sql: impl SqlSafeStr,
78+
sql: SqlStr,
7979
_parameters: &[SqliteTypeInfo],
8080
) -> BoxFuture<'e, Result<SqliteStatement, Error>>
8181
where
8282
'c: 'e,
8383
{
84-
let sql = sql.into_sql_str();
8584
Box::pin(async move {
8685
let statement = self.worker.prepare(sql).await?;
8786

@@ -90,11 +89,10 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
9089
}
9190

9291
#[doc(hidden)]
93-
fn describe<'e>(self, sql: impl SqlSafeStr) -> BoxFuture<'e, Result<Describe<Sqlite>, Error>>
92+
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Sqlite>, Error>>
9493
where
9594
'c: 'e,
9695
{
97-
let sql = sql.into_sql_str();
9896
Box::pin(async move { self.worker.describe(sql).await })
9997
}
10098
}

0 commit comments

Comments
 (0)