Replace some futures_util APIs with std variants (#3721)

This commit is contained in:
Paolo Barbolini
2025-02-02 01:01:56 +01:00
committed by GitHub
parent 5b26369a59
commit 65229f7ff9
12 changed files with 35 additions and 51 deletions

View File

@@ -17,6 +17,7 @@ use sqlx_core::database::Database;
use sqlx_core::describe::Describe;
use sqlx_core::executor::Executor;
use sqlx_core::transaction::TransactionManager;
use std::pin::pin;
sqlx_core::declare_driver_with_optional_migrate!(DRIVER = Sqlite);
@@ -105,12 +106,12 @@ impl AnyConnectionBackend for SqliteConnection {
let args = arguments.map(map_arguments);
Box::pin(async move {
let stream = self
.worker
.execute(query, args, self.row_channel_size, persistent, Some(1))
.map_ok(flume::Receiver::into_stream)
.await?;
futures_util::pin_mut!(stream);
let mut stream = pin!(
self.worker
.execute(query, args, self.row_channel_size, persistent, Some(1))
.map_ok(flume::Receiver::into_stream)
.await?
);
if let Some(Either::Right(row)) = stream.try_next().await? {
return Ok(Some(AnyRow::try_from(&row)?));

View File

@@ -8,7 +8,7 @@ use sqlx_core::describe::Describe;
use sqlx_core::error::Error;
use sqlx_core::executor::{Execute, Executor};
use sqlx_core::Either;
use std::future;
use std::{future, pin::pin};
impl<'c> Executor<'c> for &'c mut SqliteConnection {
type Database = Sqlite;
@@ -56,13 +56,11 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
let persistent = query.persistent() && arguments.is_some();
Box::pin(async move {
let stream = self
let mut stream = pin!(self
.worker
.execute(sql, arguments, self.row_channel_size, persistent, Some(1))
.map_ok(flume::Receiver::into_stream)
.try_flatten_stream();
futures_util::pin_mut!(stream);
.try_flatten_stream());
while let Some(res) = stream.try_next().await? {
if let Either::Right(row) = res {