From aa7805a5f838daa906b64eae7104584414a63e81 Mon Sep 17 00:00:00 2001 From: Manuel Transfeld Date: Tue, 22 Aug 2023 23:19:37 +0200 Subject: [PATCH] Update 'sqlx' to '0.7'. --- contrib/db_pools/lib/Cargo.toml | 3 +- contrib/db_pools/lib/src/lib.rs | 11 +-- contrib/db_pools/lib/src/pool.rs | 4 +- contrib/db_pools/lib/tests/databases.rs | 7 -- contrib/sync_db_pools/lib/Cargo.toml | 4 +- .../tests/ui-fail-stable/from_form.stderr | 6 ++ ...327afd9516143806981e11f8e34d069c14472.json | 32 ++++++++ ...78d86afd6a6d36771bfeb12f331abca6279cf.json | 12 +++ ...1ceb0bad0e473701e51ef21ecb2973c76b4df.json | 20 +++++ ...82aa1bee940f0776fae3f9962639b78328858.json | 12 +++ ...9adac27b27a3cf7bf853af3a9f130b1684d91.json | 12 +++ examples/databases/Cargo.toml | 4 +- examples/databases/sqlx-data.json | 81 ------------------- examples/databases/src/sqlx.rs | 10 +-- scripts/test.sh | 1 - site/guide/6-state.md | 6 +- 16 files changed, 113 insertions(+), 112 deletions(-) create mode 100644 examples/databases/.sqlx/query-11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472.json create mode 100644 examples/databases/.sqlx/query-3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf.json create mode 100644 examples/databases/.sqlx/query-4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df.json create mode 100644 examples/databases/.sqlx/query-668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858.json create mode 100644 examples/databases/.sqlx/query-79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91.json delete mode 100644 examples/databases/sqlx-data.json diff --git a/contrib/db_pools/lib/Cargo.toml b/contrib/db_pools/lib/Cargo.toml index af9efca2..540e5348 100644 --- a/contrib/db_pools/lib/Cargo.toml +++ b/contrib/db_pools/lib/Cargo.toml @@ -21,7 +21,6 @@ deadpool_redis = ["deadpool-redis", "deadpool"] sqlx_mysql = ["sqlx", "sqlx/mysql"] sqlx_postgres = ["sqlx", "sqlx/postgres"] sqlx_sqlite = ["sqlx", "sqlx/sqlite"] -sqlx_mssql = ["sqlx", "sqlx/mssql"] sqlx_macros = ["sqlx/macros"] # diesel features diesel_postgres = ["diesel-async/postgres", "diesel-async/deadpool", "diesel", "deadpool"] @@ -72,7 +71,7 @@ default-features = false optional = true [dependencies.sqlx] -version = "0.6" +version = "0.7" default-features = false features = ["runtime-tokio-rustls"] optional = true diff --git a/contrib/db_pools/lib/src/lib.rs b/contrib/db_pools/lib/src/lib.rs index d79fa4ea..c00375c8 100644 --- a/contrib/db_pools/lib/src/lib.rs +++ b/contrib/db_pools/lib/src/lib.rs @@ -62,7 +62,7 @@ //! #[get("/")] //! async fn read(mut db: Connection, id: i64) -> Option { //! sqlx::query("SELECT content FROM logs WHERE id = ?").bind(id) -//! .fetch_one(&mut *db).await +//! .fetch_one(&mut **db).await //! .and_then(|r| Ok(Log(r.try_get(0)?))) //! .ok() //! } @@ -113,23 +113,20 @@ //! On shutdown, new connections are denied. Shutdown _does not_ wait for //! connections to be returned. //! -//! ## `sqlx` (v0.6) +//! ## `sqlx` (v0.7) //! //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! |----------|-----------------|----------------------|------------------------------------------| //! | Postgres | `sqlx_postgres` | [`sqlx::PgPool`] | [`sqlx::pool::PoolConnection`] | //! | MySQL | `sqlx_mysql` | [`sqlx::MySqlPool`] | [`sqlx::pool::PoolConnection`] | //! | SQLite | `sqlx_sqlite` | [`sqlx::SqlitePool`] | [`sqlx::pool::PoolConnection`] | -//! | MSSQL | `sqlx_mssql` | [`sqlx::MssqlPool`] | [`sqlx::pool::PoolConnection`] | //! //! [`sqlx::PgPool`]: https://docs.rs/sqlx/0.6/sqlx/type.PgPool.html //! [`sqlx::MySqlPool`]: https://docs.rs/sqlx/0.6/sqlx/type.MySqlPool.html //! [`sqlx::SqlitePool`]: https://docs.rs/sqlx/0.6/sqlx/type.SqlitePool.html -//! [`sqlx::MssqlPool`]: https://docs.rs/sqlx/0.6/sqlx/type.MssqlPool.html //! [`sqlx::pool::PoolConnection`]: https://docs.rs/sqlx/0.6/sqlx/pool/struct.PoolConnection.html //! [`sqlx::pool::PoolConnection`]: https://docs.rs/sqlx/0.6/sqlx/pool/struct.PoolConnection.html //! [`sqlx::pool::PoolConnection`]: https://docs.rs/sqlx/0.6/sqlx/pool/struct.PoolConnection.html -//! [`sqlx::pool::PoolConnection`]: https://docs.rs/sqlx/0.6/sqlx/pool/struct.PoolConnection.html //! //! On shutdown, new connections are denied. Shutdown waits for connections to //! be returned. @@ -163,9 +160,9 @@ //! //! ```toml //! [dependencies.sqlx] -//! version = "0.6" +//! version = "0.7" //! default-features = false -//! features = ["macros", "offline", "migrate"] +//! features = ["macros", "migrate"] //! //! [dependencies.rocket_db_pools] //! version = "=0.1.0-rc.3" diff --git a/contrib/db_pools/lib/src/pool.rs b/contrib/db_pools/lib/src/pool.rs index 49d298cb..694a2064 100644 --- a/contrib/db_pools/lib/src/pool.rs +++ b/contrib/db_pools/lib/src/pool.rs @@ -253,10 +253,10 @@ mod sqlx { let mut opts = config.url.parse::>().map_err(Error::Init)?; specialize(&mut opts, &config); - opts.disable_statement_logging(); + opts = opts.disable_statement_logging(); if let Ok(level) = figment.extract_inner::(rocket::Config::LOG_LEVEL) { if !matches!(level, LogLevel::Normal | LogLevel::Off) { - opts.log_statements(level.into()) + opts = opts.log_statements(level.into()) .log_slow_statements(level.into(), Duration::default()); } } diff --git a/contrib/db_pools/lib/tests/databases.rs b/contrib/db_pools/lib/tests/databases.rs index ce0bd369..21401a25 100644 --- a/contrib/db_pools/lib/tests/databases.rs +++ b/contrib/db_pools/lib/tests/databases.rs @@ -52,13 +52,6 @@ check_types_match!( sqlx::pool::PoolConnection, ); -check_types_match!( - "sqlx_mssql", - sqlx_mssql, - sqlx::MssqlPool, - sqlx::pool::PoolConnection, -); - check_types_match!( "mongodb", mongodb, diff --git a/contrib/sync_db_pools/lib/Cargo.toml b/contrib/sync_db_pools/lib/Cargo.toml index 6ef7081d..8a2903f1 100644 --- a/contrib/sync_db_pools/lib/Cargo.toml +++ b/contrib/sync_db_pools/lib/Cargo.toml @@ -28,8 +28,8 @@ diesel = { version = "2.0.0", default-features = false, optional = true } postgres = { version = "0.19", optional = true } r2d2_postgres = { version = "0.18", optional = true } -rusqlite = { version = "0.27.0", optional = true } -r2d2_sqlite = { version = "0.20.0", optional = true } +rusqlite = { version = "0.29.0", optional = true } +r2d2_sqlite = { version = "0.22.0", optional = true } memcache = { version = "0.15", optional = true } r2d2-memcache = { version = "0.6", optional = true } diff --git a/core/codegen/tests/ui-fail-stable/from_form.stderr b/core/codegen/tests/ui-fail-stable/from_form.stderr index afd9e509..3bc006df 100644 --- a/core/codegen/tests/ui-fail-stable/from_form.stderr +++ b/core/codegen/tests/ui-fail-stable/from_form.stderr @@ -523,6 +523,9 @@ help: the type constructed contains `{integer}` due to the type of the argument | ^^^ this argument influences the type of `Some` note: tuple variant defined here --> $RUST/core/src/option.rs + | + | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | ^^^^ error[E0308]: mismatched types --> tests/ui-fail-stable/from_form.rs:203:33 @@ -542,6 +545,9 @@ help: the type constructed contains `&'static str` due to the type of the argume | this argument influences the type of `Some` note: tuple variant defined here --> $RUST/core/src/option.rs + | + | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | ^^^^ error[E0277]: the trait bound `bool: From<&str>` is not satisfied --> tests/ui-fail-stable/from_form.rs:209:23 diff --git a/examples/databases/.sqlx/query-11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472.json b/examples/databases/.sqlx/query-11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472.json new file mode 100644 index 00000000..247b40e2 --- /dev/null +++ b/examples/databases/.sqlx/query-11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472.json @@ -0,0 +1,32 @@ +{ + "db_name": "SQLite", + "query": "SELECT id, title, text FROM posts WHERE id = ?", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "title", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "text", + "ordinal": 2, + "type_info": "Text" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472" +} diff --git a/examples/databases/.sqlx/query-3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf.json b/examples/databases/.sqlx/query-3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf.json new file mode 100644 index 00000000..a78e822a --- /dev/null +++ b/examples/databases/.sqlx/query-3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO posts (title, text) VALUES (?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf" +} diff --git a/examples/databases/.sqlx/query-4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df.json b/examples/databases/.sqlx/query-4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df.json new file mode 100644 index 00000000..99a73650 --- /dev/null +++ b/examples/databases/.sqlx/query-4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT id FROM posts", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 0 + }, + "nullable": [ + false + ] + }, + "hash": "4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df" +} diff --git a/examples/databases/.sqlx/query-668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858.json b/examples/databases/.sqlx/query-668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858.json new file mode 100644 index 00000000..d744583b --- /dev/null +++ b/examples/databases/.sqlx/query-668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "DELETE FROM posts", + "describe": { + "columns": [], + "parameters": { + "Right": 0 + }, + "nullable": [] + }, + "hash": "668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858" +} diff --git a/examples/databases/.sqlx/query-79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91.json b/examples/databases/.sqlx/query-79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91.json new file mode 100644 index 00000000..6aa292f3 --- /dev/null +++ b/examples/databases/.sqlx/query-79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "DELETE FROM posts WHERE id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91" +} diff --git a/examples/databases/Cargo.toml b/examples/databases/Cargo.toml index 926105d2..63b50d17 100644 --- a/examples/databases/Cargo.toml +++ b/examples/databases/Cargo.toml @@ -11,9 +11,9 @@ diesel = "2" diesel_migrations = "2" [dependencies.sqlx] -version = "0.6.0" +version = "0.7.0" default-features = false -features = ["macros", "offline", "migrate"] +features = ["macros", "migrate"] [dependencies.rocket_db_pools] path = "../../contrib/db_pools/lib/" diff --git a/examples/databases/sqlx-data.json b/examples/databases/sqlx-data.json deleted file mode 100644 index 9dbd4945..00000000 --- a/examples/databases/sqlx-data.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "db": "SQLite", - "11e3096becb72f427c8d3911ef4327afd9516143806981e11f8e34d069c14472": { - "query": "SELECT id, title, text FROM posts WHERE id = ?", - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int64" - }, - { - "name": "title", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "text", - "ordinal": 2, - "type_info": "Text" - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false, - false, - false - ] - } - }, - "3c289da9873097a11191dbedc5c78d86afd6a6d36771bfeb12f331abca6279cf": { - "query": "INSERT INTO posts (title, text) VALUES (?, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - } - }, - "4415c35941e52a981b10707fe2e1ceb0bad0e473701e51ef21ecb2973c76b4df": { - "query": "SELECT id FROM posts", - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int64" - } - ], - "parameters": { - "Right": 0 - }, - "nullable": [ - false - ] - } - }, - "668690acaca0a0c0b4ac306b14d82aa1bee940f0776fae3f9962639b78328858": { - "query": "DELETE FROM posts", - "describe": { - "columns": [], - "parameters": { - "Right": 0 - }, - "nullable": [] - } - }, - "79301b44b77802e0096efd73b1e9adac27b27a3cf7bf853af3a9f130b1684d91": { - "query": "DELETE FROM posts WHERE id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - } - } -} \ No newline at end of file diff --git a/examples/databases/src/sqlx.rs b/examples/databases/src/sqlx.rs index ffad0c73..0f0ca67b 100644 --- a/examples/databases/src/sqlx.rs +++ b/examples/databases/src/sqlx.rs @@ -26,7 +26,7 @@ struct Post { async fn create(mut db: Connection, post: Json) -> Result>> { // There is no support for `RETURNING`. sqlx::query!("INSERT INTO posts (title, text) VALUES (?, ?)", post.title, post.text) - .execute(&mut *db) + .execute(&mut **db) .await?; Ok(Created::new("/").body(post)) @@ -35,7 +35,7 @@ async fn create(mut db: Connection, post: Json) -> Result) -> Result>> { let ids = sqlx::query!("SELECT id FROM posts") - .fetch(&mut *db) + .fetch(&mut **db) .map_ok(|record| record.id) .try_collect::>() .await?; @@ -46,7 +46,7 @@ async fn list(mut db: Connection) -> Result>> { #[get("/")] async fn read(mut db: Connection, id: i64) -> Option> { sqlx::query!("SELECT id, title, text FROM posts WHERE id = ?", id) - .fetch_one(&mut *db) + .fetch_one(&mut **db) .map_ok(|r| Json(Post { id: Some(r.id), title: r.title, text: r.text })) .await .ok() @@ -55,7 +55,7 @@ async fn read(mut db: Connection, id: i64) -> Option> { #[delete("/")] async fn delete(mut db: Connection, id: i64) -> Result> { let result = sqlx::query!("DELETE FROM posts WHERE id = ?", id) - .execute(&mut *db) + .execute(&mut **db) .await?; Ok((result.rows_affected() == 1).then(|| ())) @@ -63,7 +63,7 @@ async fn delete(mut db: Connection, id: i64) -> Result> { #[delete("/")] async fn destroy(mut db: Connection) -> Result<()> { - sqlx::query!("DELETE FROM posts").execute(&mut *db).await?; + sqlx::query!("DELETE FROM posts").execute(&mut **db).await?; Ok(()) } diff --git a/scripts/test.sh b/scripts/test.sh index 1532ee47..40525a1f 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -80,7 +80,6 @@ function test_contrib() { sqlx_mysql sqlx_postgres sqlx_sqlite - sqlx_mssql mongodb diesel_mysql diesel_postgres diff --git a/site/guide/6-state.md b/site/guide/6-state.md index 0eb6d65a..b845d347 100644 --- a/site/guide/6-state.md +++ b/site/guide/6-state.md @@ -264,7 +264,7 @@ in three simple steps: #[get("/")] async fn read(mut db: Connection, id: i64) -> Option { sqlx::query("SELECT content FROM logs WHERE id = ?").bind(id) - .fetch_one(&mut *db).await + .fetch_one(&mut **db).await .and_then(|r| Ok(r.try_get(0)?)) .ok() } @@ -294,9 +294,9 @@ features enabled in `Cargo.toml`: ```toml [dependencies.sqlx] -version = "0.6" +version = "0.7" default-features = false -features = ["macros", "offline", "migrate"] +features = ["macros", "migrate"] [dependencies.rocket_db_pools] version = "=0.1.0-rc.3"