From 2d4bd9e85380cfc6faf3e672b6cee892bccfce3d Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 16 Jul 2023 13:49:53 +0200 Subject: [PATCH] Update to latest sqlx in example (#2099) --- examples/sqlx-postgres/Cargo.toml | 3 +-- examples/sqlx-postgres/src/main.rs | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/sqlx-postgres/Cargo.toml b/examples/sqlx-postgres/Cargo.toml index 0587dc7f46..043532bcf8 100644 --- a/examples/sqlx-postgres/Cargo.toml +++ b/examples/sqlx-postgres/Cargo.toml @@ -6,8 +6,7 @@ publish = false [dependencies] axum = { path = "../../axum" } +sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "any", "postgres"] } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } - -sqlx = { version = "0.5.10", features = ["runtime-tokio-rustls", "any", "postgres"] } diff --git a/examples/sqlx-postgres/src/main.rs b/examples/sqlx-postgres/src/main.rs index 8e3353b9a1..b49ab394df 100644 --- a/examples/sqlx-postgres/src/main.rs +++ b/examples/sqlx-postgres/src/main.rs @@ -41,7 +41,7 @@ async fn main() { // setup connection pool let pool = PgPoolOptions::new() .max_connections(5) - .connect_timeout(Duration::from_secs(3)) + .acquire_timeout(Duration::from_secs(3)) .connect(&db_connection_str) .await .expect("can't connect to database"); @@ -95,11 +95,10 @@ where } async fn using_connection_extractor( - DatabaseConnection(conn): DatabaseConnection, + DatabaseConnection(mut conn): DatabaseConnection, ) -> Result { - let mut conn = conn; sqlx::query_scalar("select 'hello world from pg'") - .fetch_one(&mut conn) + .fetch_one(&mut *conn) .await .map_err(internal_error) }