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

@@ -5,7 +5,7 @@ use crate::{
use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_util::{stream, StreamExt, TryFutureExt, TryStreamExt};
use std::future;
use std::{future, pin::pin};
use sqlx_core::any::{
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
@@ -115,8 +115,7 @@ impl AnyConnectionBackend for PgConnection {
Box::pin(async move {
let arguments = arguments?;
let stream = self.run(query, arguments, 1, persistent, None).await?;
futures_util::pin_mut!(stream);
let mut stream = pin!(self.run(query, arguments, 1, persistent, None).await?);
if let Some(Either::Right(row)) = stream.try_next().await? {
return Ok(Some(AnyRow::try_from(&row)?));

View File

@@ -15,10 +15,10 @@ use crate::{
use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_core::Stream;
use futures_util::{pin_mut, TryStreamExt};
use futures_util::TryStreamExt;
use sqlx_core::arguments::Arguments;
use sqlx_core::Either;
use std::{borrow::Cow, sync::Arc};
use std::{borrow::Cow, pin::pin, sync::Arc};
async fn prepare(
conn: &mut PgConnection,
@@ -393,8 +393,7 @@ impl<'c> Executor<'c> for &'c mut PgConnection {
Box::pin(try_stream! {
let arguments = arguments?;
let s = self.run(sql, arguments, 0, persistent, metadata).await?;
pin_mut!(s);
let mut s = pin!(self.run(sql, arguments, 0, persistent, metadata).await?);
while let Some(v) = s.try_next().await? {
r#yield!(v);
@@ -420,8 +419,7 @@ impl<'c> Executor<'c> for &'c mut PgConnection {
Box::pin(async move {
let arguments = arguments?;
let s = self.run(sql, arguments, 1, persistent, metadata).await?;
pin_mut!(s);
let mut s = pin!(self.run(sql, arguments, 1, persistent, metadata).await?);
// With deferred constraints we need to check all responses as we
// could get a OK response (with uncommitted data), only to get an