MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / sqlx_bind_errors_recover_after_sync

Function sqlx_bind_errors_recover_after_sync

tests/client_compat.rs:93–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
93async fn sqlx_bind_errors_recover_after_sync() -> Result<()> {
94 let server = PgliteServer::temporary_tcp()?;
95 let mut conn = sqlx::PgConnection::connect(&server.connection_uri())
96 .await
97 .context("connect with SQLx")?;
98
99 let invalid_int = sqlx::query("SELECT $1::int4 AS value")
100 .bind("not_an_int")
101 .fetch_one(&mut conn)
102 .await
103 .expect_err("invalid int text should fail while binding a typed parameter");
104 assert_sqlx_code(&invalid_int, "22P02");
105 let row = sqlx::query("SELECT 31::int4 AS recovered_after_invalid_bind")
106 .fetch_one(&mut conn)
107 .await
108 .context("query after invalid bind value")?;
109 assert_eq!(row.try_get::<i32, _>("recovered_after_invalid_bind")?, 31);
110
111 let wrong_param_count = sqlx::query("SELECT $1::int4 + $2::int4 AS value")
112 .bind(1_i32)
113 .fetch_one(&mut conn)
114 .await
115 .expect_err("missing parameter should fail during extended-query bind");
116 assert_sqlx_code(&wrong_param_count, "08P01");
117 let row = sqlx::query("SELECT 32::int4 AS recovered_after_param_count")
118 .fetch_one(&mut conn)
119 .await
120 .context("query after wrong parameter count")?;
121 assert_eq!(row.try_get::<i32, _>("recovered_after_param_count")?, 32);
122
123 conn.close().await?;
124 server.shutdown()?;
125 Ok(())
126}
127
128#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
129async fn tokio_postgres_pipelined_extended_queries_keep_ready_state() -> Result<()> {

Callers

nothing calls this directly

Calls 5

connection_uriMethod · 0.80
bindMethod · 0.80
assert_sqlx_codeFunction · 0.70
closeMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected