mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-05 16:54:50 +00:00
add regression test for Map::fetch()
being Unpin
This commit is contained in:
parent
8deb5549b3
commit
f00b7b48e1
@ -1,6 +1,8 @@
|
|||||||
use sqlx::Postgres;
|
use sqlx::Postgres;
|
||||||
use sqlx_test::new;
|
use sqlx_test::new;
|
||||||
|
|
||||||
|
use futures::TryStreamExt;
|
||||||
|
|
||||||
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
|
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
|
||||||
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
|
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
|
||||||
async fn test_query() -> anyhow::Result<()> {
|
async fn test_query() -> anyhow::Result<()> {
|
||||||
@ -244,3 +246,21 @@ async fn test_array_from_slice() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
|
||||||
|
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
|
||||||
|
async fn fetch_is_usable_issue_224() -> anyhow::Result<()> {
|
||||||
|
// ensures that the stream returned by `query::Map::fetch()` is usable with `TryStreamExt`
|
||||||
|
let mut conn = new::<Postgres>().await?;
|
||||||
|
|
||||||
|
let mut stream =
|
||||||
|
sqlx::query!("select * from generate_series(1, 3) as series(num);").fetch(&mut conn);
|
||||||
|
|
||||||
|
// `num` is generated by a function so we can't assume it's non-null
|
||||||
|
assert_eq!(stream.try_next().await?.unwrap().num, Some(1));
|
||||||
|
assert_eq!(stream.try_next().await?.unwrap().num, Some(2));
|
||||||
|
assert_eq!(stream.try_next().await?.unwrap().num, Some(3));
|
||||||
|
assert!(stream.try_next().await?.is_none());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user