From c7ab84fc71fc637cb0cbd1f93e5730bcae6eb189 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Thu, 25 Jul 2024 12:21:02 +0200 Subject: [PATCH 1/6] Remove unused NoCombinationClause type New compiler warnings seem to highlight that this wasn't used --- diesel/src/query_builder/combination_clause.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/diesel/src/query_builder/combination_clause.rs b/diesel/src/query_builder/combination_clause.rs index 67b2ebfca804..ba7908e60df2 100644 --- a/diesel/src/query_builder/combination_clause.rs +++ b/diesel/src/query_builder/combination_clause.rs @@ -8,18 +8,6 @@ use crate::query_builder::insert_statement::InsertFromSelect; use crate::query_builder::{AsQuery, AstPass, Query, QueryFragment, QueryId, SelectQuery}; use crate::{CombineDsl, Insertable, QueryResult, RunQueryDsl, Table}; -#[derive(Debug, Clone, Copy, QueryId)] -pub(crate) struct NoCombinationClause; - -impl QueryFragment for NoCombinationClause -where - DB: Backend + DieselReserveSpecialization, -{ - fn walk_ast<'b>(&'b self, _: AstPass<'_, 'b, DB>) -> QueryResult<()> { - Ok(()) - } -} - #[derive(Debug, Copy, Clone, QueryId)] #[must_use = "Queries are only executed when calling `load`, `get_result` or similar."] /// Combine queries using a combinator like `UNION`, `INTERSECT` or `EXPECT` From 74209c469bc7ec4a6c20dbfe33326be58c6878c0 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Thu, 25 Jul 2024 16:42:08 +0200 Subject: [PATCH 2/6] make type pub to avoid warning in not test --- examples/postgres/all_about_inserts/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/postgres/all_about_inserts/src/lib.rs b/examples/postgres/all_about_inserts/src/lib.rs index 23eb4e201ecf..664ebde1d7ff 100644 --- a/examples/postgres/all_about_inserts/src/lib.rs +++ b/examples/postgres/all_about_inserts/src/lib.rs @@ -30,7 +30,7 @@ pub struct UserForm<'a> { } #[derive(Queryable, PartialEq, Debug)] -struct User { +pub struct User { id: i32, name: String, hair_color: Option, From 13c62d0edcd8701316629ca28d5640d478942684 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Thu, 25 Jul 2024 16:45:31 +0200 Subject: [PATCH 3/6] fix doc comment --- diesel_derives/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diesel_derives/src/lib.rs b/diesel_derives/src/lib.rs index 2c909941de92..ab505d02582c 100644 --- a/diesel_derives/src/lib.rs +++ b/diesel_derives/src/lib.rs @@ -467,9 +467,9 @@ pub fn derive_query_id(input: TokenStream) -> TokenStream { /// your struct__ matches __all fields in the query__, including the order and /// count. This means that field order is significant if you're using /// `#[derive(Queryable)]`. __Field name has no effect__. If you see errors while -/// loading data into a struct that derives `Queryable`: Consider using [`#[derive(Selectable)]`] -/// + `#[diesel(check_for_backend(YourBackendType))]` to check for mismatching fields at -/// compile-time. +/// loading data into a struct that derives `Queryable`: Consider using +/// [`#[derive(Selectable)]`] + `#[diesel(check_for_backend(YourBackendType))]` +/// to check for mismatching fields at compile-time. /// /// To provide custom deserialization behavior for a field, you can use /// `#[diesel(deserialize_as = SomeType)]`. If this attribute is present, Diesel From 2a1170dcbffb062820dd875f29a10001a15f880f Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 26 Jul 2024 08:34:43 +0200 Subject: [PATCH 4/6] Bump toolchain and fix clippy issues --- diesel/src/expression/array_comparison.rs | 10 +-- diesel/src/lib.rs | 78 +++++++++++------------ diesel/src/mysql/connection/mod.rs | 4 +- diesel_cli/src/config.rs | 3 + rust-toolchain | 2 +- 5 files changed, 50 insertions(+), 47 deletions(-) diff --git a/diesel/src/expression/array_comparison.rs b/diesel/src/expression/array_comparison.rs index 3c5002fc7386..bade87beea01 100644 --- a/diesel/src/expression/array_comparison.rs +++ b/diesel/src/expression/array_comparison.rs @@ -157,12 +157,12 @@ impl_selectable_expression!(NotIn); /// Diesel provided several implementations here: /// /// - An implementation for any [`Iterator`] over values -/// that implement [`AsExpression`] for the corresponding -/// sql type ST. The corresponding values clause will contain -/// bind statements for each individual value. +/// that implement [`AsExpression`] for the corresponding +/// sql type ST. The corresponding values clause will contain +/// bind statements for each individual value. /// - An implementation for select statements, that returns -/// a single field. The corresponding values clause will contain -/// the sub query. +/// a single field. The corresponding values clause will contain +/// the sub query. /// /// This trait is exposed for custom third party backends so /// that they can restrict the [`QueryFragment`] implementations diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs index baae248d3571..e6df2c7ce803 100644 --- a/diesel/src/lib.rs +++ b/diesel/src/lib.rs @@ -151,64 +151,64 @@ //! //! - `sqlite`: This feature enables the diesel sqlite backend. Enabling this feature requires per default -//! a compatible copy of `libsqlite3` for your target architecture. Alternatively, you can add `libsqlite3-sys` -//! with the `bundled` feature as a dependency to your crate so SQLite will be bundled: -//! ```toml -//! [dependencies] -//! libsqlite3-sys = { version = "0.29", features = ["bundled"] } -//! ``` +//! a compatible copy of `libsqlite3` for your target architecture. Alternatively, you can add `libsqlite3-sys` +//! with the `bundled` feature as a dependency to your crate so SQLite will be bundled: +//! ```toml +//! [dependencies] +//! libsqlite3-sys = { version = "0.29", features = ["bundled"] } +//! ``` //! - `postgres`: This feature enables the diesel postgres backend. Enabling this feature requires a compatible -//! copy of `libpq` for your target architecture. This features implies `postgres_backend` +//! copy of `libpq` for your target architecture. This features implies `postgres_backend` //! - `mysql`: This feature enables the idesel mysql backend. Enabling this feature requires a compatible copy -//! of `libmysqlclient` for your target architecture. This feature implies `mysql_backend` +//! of `libmysqlclient` for your target architecture. This feature implies `mysql_backend` //! - `postgres_backend`: This feature enables those parts of diesels postgres backend, that are not dependent -//! on `libpq`. Diesel does not provide any connection implementation with only this feature enabled. -//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the -//! postgres backend outside of diesel itself, while reusing the existing query dsl extensions for the -//! postgres backend +//! on `libpq`. Diesel does not provide any connection implementation with only this feature enabled. +//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the +//! postgres backend outside of diesel itself, while reusing the existing query dsl extensions for the +//! postgres backend //! - `mysql_backend`: This feature enables those parts of diesels mysql backend, that are not dependent -//! on `libmysqlclient`. Diesel does not provide any connection implementation with only this feature enabled. -//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the -//! mysql backend outside of diesel itself, while reusing the existing query dsl extensions for the -//! mysql backend +//! on `libmysqlclient`. Diesel does not provide any connection implementation with only this feature enabled. +//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the +//! mysql backend outside of diesel itself, while reusing the existing query dsl extensions for the +//! mysql backend //! - `returning_clauses_for_sqlite_3_35`: This feature enables support for `RETURNING` clauses in the sqlite backend. -//! Enabling this feature requires sqlite 3.35.0 or newer. +//! Enabling this feature requires sqlite 3.35.0 or newer. //! - `32-column-tables`: This feature enables support for tables with up to 32 columns. -//! This feature is enabled by default. Consider disabling this feature if you write a library crate -//! providing general extensions for diesel or if you do not need to support tables with more than 16 columns -//! and you want to minimize your compile times. +//! This feature is enabled by default. Consider disabling this feature if you write a library crate +//! providing general extensions for diesel or if you do not need to support tables with more than 16 columns +//! and you want to minimize your compile times. //! - `64-column-tables`: This feature enables support for tables with up to 64 columns. It implies the -//! `32-column-tables` feature. Enabling this feature will increase your compile times. +//! `32-column-tables` feature. Enabling this feature will increase your compile times. //! - `128-column-tables`: This feature enables support for tables with up to 128 columns. It implies the -//! `64-column-tables` feature. Enabling this feature will increase your compile times significantly. +//! `64-column-tables` feature. Enabling this feature will increase your compile times significantly. //! - `i-implement-a-third-party-backend-and-opt-into-breaking-changes`: This feature opens up some otherwise -//! private API, that can be useful to implement a third party [`Backend`](crate::backend::Backend) -//! or write a custom [`Connection`] implementation. **Do not use this feature for -//! any other usecase**. By enabling this feature you explicitly opt out diesel stability guarantees. We explicitly -//! reserve us the right to break API's exported under this feature flag in any upcoming minor version release. -//! If you publish a crate depending on this feature flag consider to restrict the supported diesel version to the -//! currently released minor version. +//! private API, that can be useful to implement a third party [`Backend`](crate::backend::Backend) +//! or write a custom [`Connection`] implementation. **Do not use this feature for +//! any other usecase**. By enabling this feature you explicitly opt out diesel stability guarantees. We explicitly +//! reserve us the right to break API's exported under this feature flag in any upcoming minor version release. +//! If you publish a crate depending on this feature flag consider to restrict the supported diesel version to the +//! currently released minor version. //! - `serde_json`: This feature flag enables support for (de)serializing json values from the database using -//! types provided by `serde_json`. +//! types provided by `serde_json`. //! - `chrono`: This feature flags enables support for (de)serializing date/time values from the database using -//! types provided by `chrono` +//! types provided by `chrono` //! - `uuid`: This feature flag enables support for (de)serializing uuid values from the database using types -//! provided by `uuid` +//! provided by `uuid` //! - `network-address`: This feature flag enables support for (de)serializing -//! IP values from the database using types provided by `ipnetwork`. +//! IP values from the database using types provided by `ipnetwork`. //! - `ipnet-address`: This feature flag enables support for (de)serializing IP -//! values from the database using types provided by `ipnet`. +//! values from the database using types provided by `ipnet`. //! - `numeric`: This feature flag enables support for (de)serializing numeric values from the database using types -//! provided by `bigdecimal` +//! provided by `bigdecimal` //! - `r2d2`: This feature flag enables support for the `r2d2` connection pool implementation. //! - `extras`: This feature enables the feature flagged support for any third party crate. This implies the -//! following feature flags: `serde_json`, `chrono`, `uuid`, `network-address`, `numeric`, `r2d2` +//! following feature flags: `serde_json`, `chrono`, `uuid`, `network-address`, `numeric`, `r2d2` //! - `with-deprecated`: This feature enables items marked as `#[deprecated]`. It is enabled by default. -//! disabling this feature explicitly opts out diesels stability guarantee. +//! disabling this feature explicitly opts out diesels stability guarantee. //! - `without-deprecated`: This feature disables any item marked as `#[deprecated]`. Enabling this feature -//! explicitly opts out the stability guarantee given by diesel. This feature overrides the `with-deprecated`. -//! Note that this may also remove items that are not shown as `#[deprecated]` in our documentation, due to -//! various bugs in rustdoc. It can be used to check if you depend on any such hidden `#[deprecated]` item. +//! explicitly opts out the stability guarantee given by diesel. This feature overrides the `with-deprecated`. +//! Note that this may also remove items that are not shown as `#[deprecated]` in our documentation, due to +//! various bugs in rustdoc. It can be used to check if you depend on any such hidden `#[deprecated]` item. //! //! By default the following features are enabled: //! diff --git a/diesel/src/mysql/connection/mod.rs b/diesel/src/mysql/connection/mod.rs index 992d92c4f915..defb55f79f60 100644 --- a/diesel/src/mysql/connection/mod.rs +++ b/diesel/src/mysql/connection/mod.rs @@ -31,7 +31,7 @@ use crate::RunQueryDsl; /// * `ssl_cert` accepts a path to the client's certificate file /// * `ssl_key` accepts a path to the client's private key file /// * `ssl_mode` expects a value defined for MySQL client command option `--ssl-mode` -/// See +/// See /// /// # Supported loading model implementations /// @@ -154,7 +154,7 @@ impl Connection for MysqlConnection { /// * `ssl_cert` accepts a path to the client's certificate file /// * `ssl_key` accepts a path to the client's private key file /// * `ssl_mode` expects a value defined for MySQL client command option `--ssl-mode` - /// See + /// See fn establish(database_url: &str) -> ConnectionResult { let mut instrumentation = crate::connection::instrumentation::get_default_instrumentation(); instrumentation.on_connection_event(InstrumentationEvent::StartEstablishConnection { diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index fb3fca7502fe..fa6a8d9ab463 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -458,6 +458,9 @@ impl PrintSchema { self.import_types.as_deref() } + // it's a false positive + // https://github.com/rust-lang/rust-clippy/issues/12856 + #[allow(clippy::needless_borrows_for_generic_args)] fn set_relative_path_base(&mut self, base: &Path) { if let Some(ref mut file) = self.file { if file.is_relative() { diff --git a/rust-toolchain b/rust-toolchain index b3a8c61e6a86..aaceec04e040 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.79.0 +1.80.0 From 223b8ebf875b4777466dc1f3c8afd1a1c9258949 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 26 Jul 2024 09:03:08 +0200 Subject: [PATCH 5/6] Update compile tests output --- .../copy_can_only_use_options_with_raw_variant.stderr | 6 +----- diesel_compile_tests/tests/fail/derive/selectable.stderr | 9 +++++++++ .../tests/fail/only_only_on_table.stderr | 2 +- ...g_specific_tablesample_cannot_be_used_on_mysql.stderr | 2 +- ..._specific_tablesample_cannot_be_used_on_sqlite.stderr | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/diesel_compile_tests/tests/fail/copy_can_only_use_options_with_raw_variant.stderr b/diesel_compile_tests/tests/fail/copy_can_only_use_options_with_raw_variant.stderr index 3c9f82c63e61..2d2f9623def0 100644 --- a/diesel_compile_tests/tests/fail/copy_can_only_use_options_with_raw_variant.stderr +++ b/diesel_compile_tests/tests/fail/copy_can_only_use_options_with_raw_variant.stderr @@ -1,11 +1,7 @@ error[E0599]: no method named `with_format` found for struct `CopyFromQuery>>` in the current scope --> tests/fail/copy_can_only_use_options_with_raw_variant.rs:49:10 | -47 | diesel::copy_from(users::table) - | ------------------------------- - | | - | _____method `with_format` is available on `CopyFromQuery` - | | +47 | / diesel::copy_from(users::table) 48 | | .from_insertable(vec![NewUser { name: "John" }]) 49 | | .with_format(CopyFormat::Csv) | | -^^^^^^^^^^^ method not found in `CopyFromQuery>>` diff --git a/diesel_compile_tests/tests/fail/derive/selectable.stderr b/diesel_compile_tests/tests/fail/derive/selectable.stderr index 0feb1521e54b..faa86fa84608 100644 --- a/diesel_compile_tests/tests/fail/derive/selectable.stderr +++ b/diesel_compile_tests/tests/fail/derive/selectable.stderr @@ -40,3 +40,12 @@ error[E0425]: cannot find value `non_existing` in module `users` | 33 | select_expression = (users::id, users::non_existing), | ^^^^^^^^^^^^ not found in `users` + +error[E0308]: mismatched types + --> tests/fail/derive/selectable.rs:38:29 + | +38 | select_expression = (users::id + 45), + | ^^^^^^^^^^^^^^^^ expected `id`, found `Add>` + | + = note: expected struct `columns::id` + found struct `diesel::expression::ops::numeric::Add>` diff --git a/diesel_compile_tests/tests/fail/only_only_on_table.stderr b/diesel_compile_tests/tests/fail/only_only_on_table.stderr index 21696e399b5f..9aa70f669dac 100644 --- a/diesel_compile_tests/tests/fail/only_only_on_table.stderr +++ b/diesel_compile_tests/tests/fail/only_only_on_table.stderr @@ -74,4 +74,4 @@ note: the trait `Table` must be implemented = note: the following trait defines an item `only`, perhaps you need to implement it: candidate #1: `diesel::dsl::OnlyDsl` -error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2 +error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2 diff --git a/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_mysql.stderr b/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_mysql.stderr index a6d2eb13fc2f..a3db46ffcddb 100644 --- a/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_mysql.stderr +++ b/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_mysql.stderr @@ -1 +1 @@ -error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2 +error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2 diff --git a/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_sqlite.stderr b/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_sqlite.stderr index a6d2eb13fc2f..a3db46ffcddb 100644 --- a/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_sqlite.stderr +++ b/diesel_compile_tests/tests/fail/pg_specific_tablesample_cannot_be_used_on_sqlite.stderr @@ -1 +1 @@ -error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2 +error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2 From 3dd18263c769e026bc176924707575661a874177 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 26 Jul 2024 09:36:46 +0200 Subject: [PATCH 6/6] Apply the pub fix also to the mysql/sqlite examples --- examples/mysql/all_about_inserts/src/lib.rs | 2 +- examples/sqlite/all_about_inserts/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mysql/all_about_inserts/src/lib.rs b/examples/mysql/all_about_inserts/src/lib.rs index e5e44cd95353..a55f3b4083c5 100644 --- a/examples/mysql/all_about_inserts/src/lib.rs +++ b/examples/mysql/all_about_inserts/src/lib.rs @@ -30,7 +30,7 @@ pub struct UserForm<'a> { } #[derive(Queryable, PartialEq, Debug)] -struct User { +pub struct User { id: i32, name: String, hair_color: Option, diff --git a/examples/sqlite/all_about_inserts/src/lib.rs b/examples/sqlite/all_about_inserts/src/lib.rs index 3a29eef3ae68..562cf8bb3092 100644 --- a/examples/sqlite/all_about_inserts/src/lib.rs +++ b/examples/sqlite/all_about_inserts/src/lib.rs @@ -30,7 +30,7 @@ pub struct UserForm<'a> { } #[derive(Queryable, PartialEq, Debug)] -struct User { +pub struct User { id: i32, name: String, hair_color: Option,