From 2b2418c6d191ca09fb5414c11455e620f19c2786 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 22 Jan 2021 14:59:04 +0100 Subject: [PATCH] Add a test for nesting `.map` --- tests/postgres/postgres.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index 4e5b107c..dee9062d 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -152,6 +152,21 @@ CREATE TEMPORARY TABLE users (id INTEGER PRIMARY KEY); Ok(()) } +#[sqlx_macros::test] +async fn it_can_nest_map() -> anyhow::Result<()> { + let mut conn = new::().await?; + + let res = sqlx::query("SELECT 5") + .map(|row: PgRow| row.get(0)) + .map(|int: i32| int.to_string()) + .fetch_one(&mut conn) + .await?; + + assert_eq!(res, "5"); + + Ok(()) +} + #[cfg(feature = "json")] #[sqlx_macros::test] async fn it_describes_and_inserts_json_and_jsonb() -> anyhow::Result<()> {