mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
use the persistent query setting with the Any driver (#3297)
This commit is contained in:
parent
0db12a9846
commit
b71221cd74
5 changed files with 18 additions and 8 deletions
|
@ -72,12 +72,14 @@ pub trait AnyConnectionBackend: std::any::Any + Debug + Send + 'static {
|
||||||
fn fetch_many<'q>(
|
fn fetch_many<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxStream<'q, crate::Result<Either<AnyQueryResult, AnyRow>>>;
|
) -> BoxStream<'q, crate::Result<Either<AnyQueryResult, AnyRow>>>;
|
||||||
|
|
||||||
fn fetch_optional<'q>(
|
fn fetch_optional<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxFuture<'q, crate::Result<Option<AnyRow>>>;
|
) -> BoxFuture<'q, crate::Result<Option<AnyRow>>>;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
|
||||||
Ok(arguments) => arguments,
|
Ok(arguments) => arguments,
|
||||||
Err(error) => return stream::once(future::ready(Err(error))).boxed(),
|
Err(error) => return stream::once(future::ready(Err(error))).boxed(),
|
||||||
};
|
};
|
||||||
self.backend.fetch_many(query.sql(), arguments)
|
self.backend
|
||||||
|
.fetch_many(query.sql(), query.persistent(), arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_optional<'e, 'q: 'e, E>(
|
fn fetch_optional<'e, 'q: 'e, E>(
|
||||||
|
@ -38,7 +39,8 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
|
||||||
Ok(arguments) => arguments,
|
Ok(arguments) => arguments,
|
||||||
Err(error) => return future::ready(Err(error)).boxed(),
|
Err(error) => return future::ready(Err(error)).boxed(),
|
||||||
};
|
};
|
||||||
self.backend.fetch_optional(query.sql(), arguments)
|
self.backend
|
||||||
|
.fetch_optional(query.sql(), query.persistent(), arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_with<'e, 'q: 'e>(
|
fn prepare_with<'e, 'q: 'e>(
|
||||||
|
|
|
@ -75,9 +75,10 @@ impl AnyConnectionBackend for MySqlConnection {
|
||||||
fn fetch_many<'q>(
|
fn fetch_many<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let arguments = match arguments.as_ref().map(AnyArguments::convert_to).transpose() {
|
let arguments = match arguments.as_ref().map(AnyArguments::convert_to).transpose() {
|
||||||
Ok(arguments) => arguments,
|
Ok(arguments) => arguments,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
@ -100,9 +101,10 @@ impl AnyConnectionBackend for MySqlConnection {
|
||||||
fn fetch_optional<'q>(
|
fn fetch_optional<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let arguments = arguments
|
let arguments = arguments
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(AnyArguments::convert_to)
|
.map(AnyArguments::convert_to)
|
||||||
|
|
|
@ -74,9 +74,10 @@ impl AnyConnectionBackend for PgConnection {
|
||||||
fn fetch_many<'q>(
|
fn fetch_many<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let arguments = match arguments.as_ref().map(AnyArguments::convert_to).transpose() {
|
let arguments = match arguments.as_ref().map(AnyArguments::convert_to).transpose() {
|
||||||
Ok(arguments) => arguments,
|
Ok(arguments) => arguments,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
@ -99,9 +100,10 @@ impl AnyConnectionBackend for PgConnection {
|
||||||
fn fetch_optional<'q>(
|
fn fetch_optional<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let arguments = arguments
|
let arguments = arguments
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(AnyArguments::convert_to)
|
.map(AnyArguments::convert_to)
|
||||||
|
|
|
@ -75,9 +75,10 @@ impl AnyConnectionBackend for SqliteConnection {
|
||||||
fn fetch_many<'q>(
|
fn fetch_many<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
) -> BoxStream<'q, sqlx_core::Result<Either<AnyQueryResult, AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let args = arguments.map(map_arguments);
|
let args = arguments.map(map_arguments);
|
||||||
|
|
||||||
Box::pin(
|
Box::pin(
|
||||||
|
@ -97,9 +98,10 @@ impl AnyConnectionBackend for SqliteConnection {
|
||||||
fn fetch_optional<'q>(
|
fn fetch_optional<'q>(
|
||||||
&'q mut self,
|
&'q mut self,
|
||||||
query: &'q str,
|
query: &'q str,
|
||||||
|
persistent: bool,
|
||||||
arguments: Option<AnyArguments<'q>>,
|
arguments: Option<AnyArguments<'q>>,
|
||||||
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
) -> BoxFuture<'q, sqlx_core::Result<Option<AnyRow>>> {
|
||||||
let persistent = arguments.is_some();
|
let persistent = persistent && arguments.is_some();
|
||||||
let args = arguments.map(map_arguments);
|
let args = arguments.map(map_arguments);
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
|
|
Loading…
Reference in a new issue