mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Add a test showing a bug in describe/execute combo
This commit is contained in:
parent
9839043b6d
commit
a4dc3dfbd7
1 changed files with 27 additions and 0 deletions
|
@ -116,6 +116,33 @@ CREATE TEMPORARY TABLE users (id INTEGER PRIMARY KEY);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "json")]
|
||||||
|
#[sqlx_macros::test]
|
||||||
|
async fn it_describes_and_inserts_json() -> anyhow::Result<()> {
|
||||||
|
let mut conn = new::<Postgres>().await?;
|
||||||
|
|
||||||
|
let _ = conn
|
||||||
|
.execute(
|
||||||
|
r#"
|
||||||
|
CREATE TEMPORARY TABLE json_stuff (id INTEGER PRIMARY KEY, obj json);
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let query = "INSERT INTO json_stuff (id, obj) VALUES ($1, $2)";
|
||||||
|
let _ = conn.describe(query).await?;
|
||||||
|
|
||||||
|
let cnt = sqlx::query(query)
|
||||||
|
.bind(1)
|
||||||
|
.bind(serde_json::json!({ "a": "a" }))
|
||||||
|
.execute(&mut conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert_eq!(cnt, 1);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[sqlx_macros::test]
|
#[sqlx_macros::test]
|
||||||
async fn it_executes_with_pool() -> anyhow::Result<()> {
|
async fn it_executes_with_pool() -> anyhow::Result<()> {
|
||||||
let pool = sqlx_test::pool::<Postgres>().await?;
|
let pool = sqlx_test::pool::<Postgres>().await?;
|
||||||
|
|
Loading…
Reference in a new issue