From b57178dcb54faf089ac0e168d791aca605a1fbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Ka=C5=BAmierczak?= Date: Sat, 19 Dec 2020 09:05:36 +0100 Subject: [PATCH] sqlite test - prepared statements are reset after fetch_one --- tests/sqlite/sqlite.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/sqlite/sqlite.rs b/tests/sqlite/sqlite.rs index 1761fdc3e4..d6c8cb5c46 100644 --- a/tests/sqlite/sqlite.rs +++ b/tests/sqlite/sqlite.rs @@ -485,3 +485,22 @@ async fn it_can_prepare_then_execute() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn it_resets_prepared_statement_after_fetch_one() -> anyhow::Result<()> { + let mut conn = new::().await?; + + conn.execute("CREATE TEMPORARY TABLE foobar (id INTEGER)") + .await?; + conn.execute("INSERT INTO foobar VALUES (42)").await?; + + let r = sqlx::query("SELECT id FROM foobar") + .fetch_one(&mut conn) + .await?; + let x: i32 = r.try_get("id")?; + assert_eq!(x, 42); + + conn.execute("DROP TABLE foobar").await?; + + Ok(()) +}