From 41d6ca406ad92f7d78b5c89d3d89df90b3815a99 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Wed, 24 Apr 2024 18:33:39 +0200 Subject: [PATCH 01/16] Add the skip missing sql_type definitions --- diesel_cli/src/config.rs | 2 ++ diesel_cli/src/print_schema.rs | 48 ++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index adee31571385..b4cefcab812b 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -415,6 +415,8 @@ pub struct PrintSchema { #[serde(default)] pub generate_missing_sql_type_definitions: Option, #[serde(default)] + pub skip_missing_sql_type_definitions: Vec, + #[serde(default)] pub custom_type_derives: Option>, #[serde(default)] pub sqlite_integer_primary_key_is_bigint: Option, diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index 3c492c6c9e0b..6f809ce05ddc 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -184,27 +184,29 @@ pub fn output_schema( .map(|c| { Some(&c.ty) .filter(|ty| !diesel_provided_types.contains(ty.rust_name.as_str())) - .map(|ty| match backend { - #[cfg(feature = "postgres")] - Backend::Pg => ty.clone(), - #[cfg(feature = "sqlite")] - Backend::Sqlite => ty.clone(), - #[cfg(feature = "mysql")] - Backend::Mysql => { - // For MySQL we generate custom types for unknown types that - // are dedicated to the column - use heck::ToUpperCamelCase; - - ColumnType { - rust_name: format!( - "{} {} {}", - &t.name.rust_name, &c.rust_name, &ty.rust_name - ) - .to_upper_camel_case(), - ..ty.clone() + // Skip types that are that match the regexes in the configuration + .filter(|ty| !config.skip_missing_sql_type_definitions.iter().any(|rx| rx.is_match(ty.rust_name.as_str()))) + .map(|ty| match backend { + #[cfg(feature = "postgres")] + Backend::Pg => ty.clone(), + #[cfg(feature = "sqlite")] + Backend::Sqlite => ty.clone(), + #[cfg(feature = "mysql")] + Backend::Mysql => { + // For MySQL we generate custom types for unknown types that + // are dedicated to the column + use heck::ToUpperCamelCase; + + ColumnType { + rust_name: format!( + "{} {} {}", + &t.name.rust_name, &c.rust_name, &ty.rust_name + ) + .to_upper_camel_case(), + ..ty.clone() + } } - } - }) + }) }) .collect::>>() }) @@ -242,7 +244,7 @@ pub fn output_schema( "{}", CustomTypesForTablesForDisplay { custom_types: custom_types_for_tables, - tables: &definitions.tables + tables: &definitions.tables, } )?; } @@ -457,7 +459,7 @@ impl<'a> Display for ModuleDefinition<'a> { "{}", CustomTypesForTablesForDisplay { custom_types: custom_types_for_tables, - tables: &self.1.tables + tables: &self.1.tables, } )?; } @@ -495,7 +497,7 @@ impl<'a> Display for TableDefinitions<'a> { custom_type_overrides: self .custom_types_for_tables .as_ref() - .map(|cts| cts.types_overrides_sorted[table_idx].as_slice()) + .map(|cts| cts.types_overrides_sorted[table_idx].as_slice()), } )?; } From 79fd9e5ef826e18700dad516b5f166aaa3fdc6de Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Wed, 24 Apr 2024 18:42:38 +0200 Subject: [PATCH 02/16] remove formatting --- diesel_cli/src/print_schema.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index 6f809ce05ddc..f25c61bba941 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -244,7 +244,7 @@ pub fn output_schema( "{}", CustomTypesForTablesForDisplay { custom_types: custom_types_for_tables, - tables: &definitions.tables, + tables: &definitions.tables } )?; } @@ -459,7 +459,7 @@ impl<'a> Display for ModuleDefinition<'a> { "{}", CustomTypesForTablesForDisplay { custom_types: custom_types_for_tables, - tables: &self.1.tables, + tables: &self.1.tables } )?; } @@ -497,7 +497,7 @@ impl<'a> Display for TableDefinitions<'a> { custom_type_overrides: self .custom_types_for_tables .as_ref() - .map(|cts| cts.types_overrides_sorted[table_idx].as_slice()), + .map(|cts| cts.types_overrides_sorted[table_idx].as_slice()) } )?; } From 9e1c0818e8111ea2929c86bf103addd2e230ff4f Mon Sep 17 00:00:00 2001 From: sabati Date: Wed, 24 Apr 2024 21:11:27 +0000 Subject: [PATCH 03/16] fmt --- diesel_cli/src/print_schema.rs | 47 +++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index f25c61bba941..5eaf188aeb46 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -185,28 +185,33 @@ pub fn output_schema( Some(&c.ty) .filter(|ty| !diesel_provided_types.contains(ty.rust_name.as_str())) // Skip types that are that match the regexes in the configuration - .filter(|ty| !config.skip_missing_sql_type_definitions.iter().any(|rx| rx.is_match(ty.rust_name.as_str()))) - .map(|ty| match backend { - #[cfg(feature = "postgres")] - Backend::Pg => ty.clone(), - #[cfg(feature = "sqlite")] - Backend::Sqlite => ty.clone(), - #[cfg(feature = "mysql")] - Backend::Mysql => { - // For MySQL we generate custom types for unknown types that - // are dedicated to the column - use heck::ToUpperCamelCase; - - ColumnType { - rust_name: format!( - "{} {} {}", - &t.name.rust_name, &c.rust_name, &ty.rust_name - ) - .to_upper_camel_case(), - ..ty.clone() - } + .filter(|ty| { + !config + .skip_missing_sql_type_definitions + .iter() + .any(|rx| rx.is_match(ty.rust_name.as_str())) + }) + .map(|ty| match backend { + #[cfg(feature = "postgres")] + Backend::Pg => ty.clone(), + #[cfg(feature = "sqlite")] + Backend::Sqlite => ty.clone(), + #[cfg(feature = "mysql")] + Backend::Mysql => { + // For MySQL we generate custom types for unknown types that + // are dedicated to the column + use heck::ToUpperCamelCase; + + ColumnType { + rust_name: format!( + "{} {} {}", + &t.name.rust_name, &c.rust_name, &ty.rust_name + ) + .to_upper_camel_case(), + ..ty.clone() } - }) + } + }) }) .collect::>>() }) From 6f3b5040a286136450fb73bc52d2cea9d38aad17 Mon Sep 17 00:00:00 2001 From: sabati Date: Wed, 24 Apr 2024 21:23:57 +0000 Subject: [PATCH 04/16] Add CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09bd02a6fa4e..a9cb0807c5d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added +* Support `[print_schema] skip_missing_sql_type_definitions=["Vector"]`. If a `missing type` matches one element on the list it's skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions * Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. From 236bbeb5561f5326fd9379645d26f8c7e2a5c3a8 Mon Sep 17 00:00:00 2001 From: sabati Date: Wed, 24 Apr 2024 22:26:39 +0000 Subject: [PATCH 05/16] Add test --- diesel_cli/tests/print_schema.rs | 5 ++++ .../diesel.toml | 4 ++++ .../postgres/expected.snap | 23 +++++++++++++++++++ .../postgres/schema.sql | 8 +++++++ 4 files changed, 40 insertions(+) create mode 100644 diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml create mode 100644 diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap create mode 100644 diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index 1d660d8a28f5..d513d08d60b7 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -10,6 +10,11 @@ fn run_infer_schema_without_docs() { test_print_schema("print_schema_simple_without_docs", vec![]); } +#[test] +fn run_skip_missing_sql_types_definitions() { + test_print_schema("print_schema_skip_missing_sql_type_definitions", vec![]); +} + #[test] fn run_infer_schema() { test_print_schema("print_schema_simple", vec!["--with-docs"]); diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml new file mode 100644 index 000000000000..269d6b9e28bd --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml @@ -0,0 +1,4 @@ +[print_schema] +file = "src/schema.rs" +generate_missing_sql_type_definitions = true +skip_missing_sql_type_definitions = ["MyType2"] diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap new file mode 100644 index 000000000000..03a27a812030 --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap @@ -0,0 +1,23 @@ +--- +source: diesel_cli/tests/print_schema.rs +description: "Test: print_schema_custom_types_check_default_derives" +--- +// @generated automatically by Diesel CLI. + +pub mod sql_types { + #[derive(diesel::sql_types::SqlType)] + #[diesel(postgres_type(name = "my_type"))] + pub struct MyType; +} + +diesel::table! { + use diesel::sql_types::*; + use super::sql_types::MyType; + + custom_types (id) { + id -> Int4, + custom_enum -> MyType, + custom_enum_nullable -> Nullable, + custom_enum2 -> MyType2, + } +} diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql new file mode 100644 index 000000000000..b346a85ceaed --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql @@ -0,0 +1,8 @@ +CREATE TYPE my_type AS ENUM ('foo', 'bar'); +CREATE TYPE my_type2 AS ENUM ('foo', 'bar'); +CREATE TABLE custom_types ( + id SERIAL PRIMARY KEY, + custom_enum my_type NOT NULL, + custom_enum_nullable my_type, + custom_enum2 my_type2 NOT NULL +); From 7081c43a80a4367e2ea5ff5893c4360f0201b8d9 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 11:33:55 +0200 Subject: [PATCH 06/16] Reanamed the command and tried to test it. --- CHANGELOG.md | 2 +- diesel_cli/src/cli.rs | 20 ++++++++++++------- diesel_cli/src/config.rs | 2 +- diesel_cli/src/print_schema.rs | 4 +++- diesel_cli/tests/print_schema.rs | 4 ++-- .../diesel.toml | 3 +++ .../postgres/expected.snap | 0 .../postgres/schema.sql | 0 .../diesel.toml | 4 ---- 9 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml rename diesel_cli/tests/print_schema/{print_schema_skip_missing_sql_type_definitions => print_schema_except_custom_type_definitions}/postgres/expected.snap (100%) rename diesel_cli/tests/print_schema/{print_schema_skip_missing_sql_type_definitions => print_schema_except_custom_type_definitions}/postgres/schema.sql (100%) delete mode 100644 diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index a9cb0807c5d4..3b66efd35711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Support `[print_schema] skip_missing_sql_type_definitions=["Vector"]`. If a `missing type` matches one element on the list it's skipped. +* Support `[print_schema] exclude_custom_sql_type_definitions=["Vector"]`. If a `missing type` matches one element on the list it's skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions * Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. diff --git a/diesel_cli/src/cli.rs b/diesel_cli/src/cli.rs index a160a3e0bf9e..43b269270738 100644 --- a/diesel_cli/src/cli.rs +++ b/diesel_cli/src/cli.rs @@ -307,6 +307,12 @@ pub fn build_cli() -> Command { .action(ArgAction::Append) .help("Generate SQL type definitions for types not provided by diesel"), ) + .arg( + Arg::new("except-custom-type-definitions").action(ArgAction::Append) + .long("except-custom-type-definitions") + .num_args(1..) + .help("A list of regexes to filter the custom types definitions generated") + ) .arg( Arg::new("custom-type-derives") .long("custom-type-derives") @@ -322,15 +328,15 @@ pub fn build_cli() -> Command { .default_values(["default"]) .help("select schema key from diesel.toml, use 'default' for print_schema without key."), ).arg( - position_sensitive_flag(Arg::new("sqlite-integer-primary-key-is-bigint")) - .long("sqlite-integer-primary-key-is-bigint") - .action(ArgAction::Append) - .help( - "For SQLite 3.37 and above, detect `INTEGER PRIMARY KEY` columns as `BigInt`, \ + position_sensitive_flag(Arg::new("sqlite-integer-primary-key-is-bigint")) + .long("sqlite-integer-primary-key-is-bigint") + .action(ArgAction::Append) + .help( + "For SQLite 3.37 and above, detect `INTEGER PRIMARY KEY` columns as `BigInt`, \ when the table isn't declared with `WITHOUT ROWID`.\n\ See https://www.sqlite.org/lang_createtable.html#rowid for more information." - ), - ); + ), + ); let config_arg = Arg::new("CONFIG_FILE") .value_parser(clap::value_parser!(std::path::PathBuf)) diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index b4cefcab812b..8cf3a37ea3e9 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -415,7 +415,7 @@ pub struct PrintSchema { #[serde(default)] pub generate_missing_sql_type_definitions: Option, #[serde(default)] - pub skip_missing_sql_type_definitions: Vec, + pub except_custom_type_definitions: Vec, #[serde(default)] pub custom_type_derives: Option>, #[serde(default)] diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index 5eaf188aeb46..c81ff08c6232 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -175,6 +175,8 @@ pub fn output_schema( Backend::Mysql => mysql_diesel_types(), }; + dbg!(config); + Some( table_data .iter() @@ -187,7 +189,7 @@ pub fn output_schema( // Skip types that are that match the regexes in the configuration .filter(|ty| { !config - .skip_missing_sql_type_definitions + .except_custom_type_definitions .iter() .any(|rx| rx.is_match(ty.rust_name.as_str())) }) diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index d513d08d60b7..5fee932cef29 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -11,8 +11,8 @@ fn run_infer_schema_without_docs() { } #[test] -fn run_skip_missing_sql_types_definitions() { - test_print_schema("print_schema_skip_missing_sql_type_definitions", vec![]); +fn run_except_custom_type_definitions() { + test_print_schema("print_schema_except_custom_type_definitions", vec!["--except-custom-type-definitions=MyType2"]); } #[test] diff --git a/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml new file mode 100644 index 000000000000..78497bb92c21 --- /dev/null +++ b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml @@ -0,0 +1,3 @@ +[print_schema] +file = "src/schema.rs" +except_custom_sql_type_definitions = ["MyType2"] diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap similarity index 100% rename from diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/expected.snap rename to diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/schema.sql similarity index 100% rename from diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/postgres/schema.sql rename to diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/schema.sql diff --git a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml b/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml deleted file mode 100644 index 269d6b9e28bd..000000000000 --- a/diesel_cli/tests/print_schema/print_schema_skip_missing_sql_type_definitions/diesel.toml +++ /dev/null @@ -1,4 +0,0 @@ -[print_schema] -file = "src/schema.rs" -generate_missing_sql_type_definitions = true -skip_missing_sql_type_definitions = ["MyType2"] From b9b6d91a8880be64e54910dd1bf69c579b0d0f17 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 11:35:31 +0200 Subject: [PATCH 07/16] update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b66efd35711..0bf5be124b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Support `[print_schema] exclude_custom_sql_type_definitions=["Vector"]`. If a `missing type` matches one element on the list it's skipped. +* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions * Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. From 6c2cbbb69f56c46df215f603e0bb1c00e0d82738 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 11:37:18 +0200 Subject: [PATCH 08/16] fmt --- diesel_cli/tests/print_schema.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index 5fee932cef29..57b7ecab2fd3 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -12,7 +12,10 @@ fn run_infer_schema_without_docs() { #[test] fn run_except_custom_type_definitions() { - test_print_schema("print_schema_except_custom_type_definitions", vec!["--except-custom-type-definitions=MyType2"]); + test_print_schema( + "print_schema_except_custom_type_definitions", + vec!["--except-custom-type-definitions=MyType2"], + ); } #[test] From 722a1346cc75855699bc020cbfbe30e5039fb326 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 11:48:24 +0200 Subject: [PATCH 09/16] remove dbg --- diesel_cli/src/print_schema.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index c81ff08c6232..fe17e217a681 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -175,8 +175,6 @@ pub fn output_schema( Backend::Mysql => mysql_diesel_types(), }; - dbg!(config); - Some( table_data .iter() From 48d4c1464683906f2ae54aeb6a2ebf54e1583868 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 16:42:47 +0200 Subject: [PATCH 10/16] typo in the CHANGELOG.md --- CHANGELOG.md | 157 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf5be124b65..d4d69c776899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,16 +12,22 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped. +* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's + skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions -* Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. -* Added an optional `#[diesel(skip_insertion)]` field attribute to the `Insertable` derive macro, allowing fields which map to generated columns to be skipped during insertion. +* Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most + of the time, in turn enabling most queries to be written using just a `Selectable` derive. +* Added an optional `#[diesel(skip_insertion)]` field attribute to the `Insertable` derive macro, allowing fields which + map to generated columns to be skipped during insertion. * Support for connection instrumentation. This allows to inspect any query run by your application * Logging in diesel-cli * Support for libsqlite3-sys 0.28 -* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)). -* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating multiple schema.rs files +* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to + use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` + attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)). +* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating + multiple schema.rs files * Add support for `COPY TO` and `COPY FROM` statements ### Changed @@ -37,8 +43,11 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to support serialization/deserialization of SQLite databases to and from byte buffers. -* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope with `sqlite3_free`. +* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to + support serialization/deserialization of SQLite databases to and from byte buffers. +* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by + calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope + with `sqlite3_free`. * Added the `custom_type_derives` config option to customize the derives for SQL type definitions automatically generated by Diesel CLI. * Add a `#[derive(MultiConnection)]` proc-macro that lets you easily implement `diesel::Connection` @@ -55,9 +64,12 @@ Increasing the minimal supported Rust version will always be coupled at least wi ## Fixed -* Workaround the missing name resolution in rust-analyzer. This should fix type inference for some diesel queries. (It remains broken for queries containing `.filter()`/`.inner_join()`/`.left_join()`. These require fixes in rust-analyzer itself) +* Workaround the missing name resolution in rust-analyzer. This should fix type inference for some diesel queries. (It + remains broken for queries containing `.filter()`/`.inner_join()`/`.left_join()`. These require fixes in rust-analyzer + itself) * Fixed a bug that could lead to inserting null values instead of empty values for custom sqlite types -* Fixed a bug that could lead to an unexpected panic while providing an out of bounds bind for `sql_query` in the sqlite backend +* Fixed a bug that could lead to an unexpected panic while providing an out of bounds bind for `sql_query` in the sqlite + backend * Fixed some mysql backend specific impl being behind the `mysql` instead of the `mysql_backend` feature flag ## Added @@ -74,7 +86,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi ## Fixed -* Fixed a bug with our transaction manager implementation that caused by marking transactions as broken which could be recovered. +* Fixed a bug with our transaction manager implementation that caused by marking transactions as broken which could be + recovered. * Fixed an issue with the combination of `BoxableExpression` and order clauses ## [2.0.2] 2022-10-11 @@ -87,7 +100,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Fixed -* Fixed an issue with `diesel_cli` generating incompatible type names for the `generate_missing_sql_type_definitions` feature on PostgreSQL +* Fixed an issue with `diesel_cli` generating incompatible type names for the `generate_missing_sql_type_definitions` + feature on PostgreSQL * Fixed an issue how `diesel_cli` handles sqlite urls while checking if a given database exists * Fixed an issue with `PgConnection` becoming unusable after hitting a database error in certain situations * Fixed an issue with diesel generating invalid SQL for certain `INSERT … ON CONFLICT` queries @@ -97,9 +111,14 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* `MysqlConnection::establish` is able to initiate an SSL connection while specifying certificate roots. The database URL should contain an `ssl_ca` parameter with a path pointing to the certificate roots. [See docs](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-ca) if desired. +* `MysqlConnection::establish` is able to initiate an SSL connection while specifying certificate roots. The database + URL should contain an `ssl_ca` parameter with a path pointing to the certificate + roots. [See docs](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-ca) if desired. -* `MysqlConnection::establish` is able to initiate an SSL connection. The database URL should contain `ssl_mode` parameter with a value of the [MySQL client command option `--ssl-mode`](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode) if desired. +* `MysqlConnection::establish` is able to initiate an SSL connection. The database URL should contain `ssl_mode` + parameter with a value of + the [MySQL client command option `--ssl-mode`](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode) + if desired. * `Connection` and `SimpleConnection` traits are implemented for a broader range of `r2d2::PooledConnection` types when the `r2d2` feature is enabled. @@ -157,9 +176,11 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Added support for SQL functions without arguments for SQLite. -* Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It's possible to disable this behavior via the `generate_missing_sql_type_definitions` config option. +* Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It's + possible to disable this behavior via the `generate_missing_sql_type_definitions` config option. -* Added an option to `#[derive(Insertable)]` that let you insert `NULL` values instead of `DEFAULT` values for `Option` +* Added an option to `#[derive(Insertable)]` that let you insert `NULL` values instead of `DEFAULT` values + for `Option` * Added support for all the derive attributes being inside `#[diesel(...)]` @@ -214,6 +235,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi should check the relevant section of [the migration guide][2-0-migration]. [backend-2-0-0]: http://docs.diesel.rs/diesel/backend/trait.Backend.html + [raw-value-2-0-0]: http://docs.diesel.rs/diesel/backend/type.RawValue.html * The type metadata for MySQL has been changed to include sign information. If @@ -247,8 +269,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi introduce a wild card match instead. * `FromSql::from_sql` is changed to construct value from non nullable database values. - To construct a rust value for nullable values use the new `FromSql::from_nullable_sql` - method instead. + To construct a rust value for nullable values use the new `FromSql::from_nullable_sql` + method instead. * Custom sql types are now required to implement the new `SqlType` trait. Diesel will automatically create implementations of that trait for all types having a `#[derive(SqlType)]` @@ -296,7 +318,9 @@ Increasing the minimal supported Rust version will always be coupled at least wi * The sqlite backend now uses a single batch insert statement if there are now default values present in the values clause -* The MySQL connection is using the CLIENT_FOUND_ROWS from now on. This means that updating rows without changing any values will return the number of matched rows (like most other SQL servers do), as opposed to the number of changed rows. +* The MySQL connection is using the CLIENT_FOUND_ROWS from now on. This means that updating rows without changing any + values will return the number of matched rows (like most other SQL servers do), as opposed to the number of changed + rows. * The definition of `ToSql::to_sql` and `QueryFragment::walk_ast` has changed to allow serializing values without copying the value itself. This is useful for database backends like sqlite where you can directly share a buffer @@ -304,10 +328,10 @@ Increasing the minimal supported Rust version will always be coupled at least wi all cases. * The `PIPES_AS_CONCAT` sql_mode is no longer set -by default. This setting requires a modification to MySQL query parsing that is -not supported by certain systems (such as Vitess). If you are using MySQL and -executing raw queries with the `||` operator, you will need to rewrite your -queries or set `PIPES_AS_CONCAT` manually. + by default. This setting requires a modification to MySQL query parsing that is + not supported by certain systems (such as Vitess). If you are using MySQL and + executing raw queries with the `||` operator, you will need to rewrite your + queries or set `PIPES_AS_CONCAT` manually. ### Fixed @@ -354,7 +378,8 @@ queries or set `PIPES_AS_CONCAT` manually. * Implementations of custom SQLite SQL functions now check for panics -* `diesel print-schema` now generates `Array>` rather than `Array` for Postgres Array types. Existence of +* `diesel print-schema` now generates `Array>` rather than `Array` for Postgres Array types. Existence + of `NULL` values in database arrays would previously result in deserialization errors. Non-nullable arrays are now opt in (by schema patching). @@ -370,8 +395,7 @@ queries or set `PIPES_AS_CONCAT` manually. Please use `diesel::upsert` instead. * `diesel::dsl::any` and `diesel::dsl::all` are now deprecated in - favour of `ExpressionMethods::eq_any()` and `ExpressionMethods::ne_all()` - + favour of `ExpressionMethods::eq_any()` and `ExpressionMethods::ne_all()` [2-0-migration]: https://github.com/diesel-rs/diesel/blob/master/guide_drafts/migration_guide.md @@ -379,7 +403,8 @@ queries or set `PIPES_AS_CONCAT` manually. ### Fixed -* Fixed a incompatibly between `diesel` and `diesel_migrations` when building both crates with cargos new `resolver = "2"` enabled. This change ensures compatibility with the upcoming 2021 rust edition. +* Fixed a incompatibly between `diesel` and `diesel_migrations` when building both crates with cargos + new `resolver = "2"` enabled. This change ensures compatibility with the upcoming 2021 rust edition. ## [1.4.7] - 2021-06-08 @@ -424,7 +449,6 @@ queries or set `PIPES_AS_CONCAT` manually. * Fixed issue where rustdoc failed to build the documentation * `diesel_derives` and `diesel_migrations` are updated to syn 1.0 - ## [1.4.2] - 2019-03-19 ### Fixed @@ -475,7 +499,7 @@ queries or set `PIPES_AS_CONCAT` manually. example, if one of the fields has the type `Cow<'a, str>`). To define an association to such a type, write `#[belongs_to(parent = "User<'_>")]` -* `Nullable` now supports `ilike` expression on in PostgreSQL. +* `Nullable` now supports `ilike` expression on in PostgreSQL. * `diesel_manage_updated_at('table_name')` is now available on SQLite. This function can be called in your migrations to create a trigger which @@ -646,6 +670,7 @@ queries or set `PIPES_AS_CONCAT` manually. [`SqliteConnection::exclusive_transaction`] for details [`SqliteConnection::immediate_transaction`]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.immediate_transaction + [`SqliteConnection::exclusive_transaction`]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.exclusive_transaction * Tables with more than 56 columns are now supported by enabling the @@ -807,6 +832,7 @@ queries or set `PIPES_AS_CONCAT` manually. `Cargo.toml`. [rust-deprecation-bug-1]: https://github.com/rust-lang/rust/issues/47236 + [rust-deprecation-bug-2]: https://github.com/rust-lang/rust/issues/47237 * Deprecated `impl_query_id!` in favor of `#[derive(QueryId)]` @@ -1095,6 +1121,7 @@ queries or set `PIPES_AS_CONCAT` manually. `1`. [bigdecimal-0.16.0]: https://crates.io/crates/bigdecimal + [range-0.16.0]: https://docs.diesel.rs/diesel/pg/types/sql_types/struct.Range.html ## [0.15.2] - 2017-07-28 @@ -1163,8 +1190,11 @@ queries or set `PIPES_AS_CONCAT` manually. * Added the [`insert_default_values`][insert-default-0.14.0] function. [pg-network-0.14.0]: https://www.postgresql.org/docs/9.6/static/datatype-net-types.html + [not-0.14.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.not.html + [insert-default-0.14.0]: https://docs.diesel.rs/diesel/fn.insert_default_values.html + [bigdecimal-0.14.0]: https://crates.io/crates/bigdecimal * Added `diesel_prefix_operator!` which behaves identically to @@ -1255,7 +1285,8 @@ queries or set `PIPES_AS_CONCAT` manually. [pg-money-0.12.0]: https://www.postgresql.org/docs/9.6/static/datatype-money.html -* Diesel CLI: Added `db` as an alias for `database`, so you can now write `diesel db setup` (which is almost 40% faster!). +* Diesel CLI: Added `db` as an alias for `database`, so you can now write `diesel db setup` (which is almost 40% + faster!). * The `table!` macro now allows you to use types from crates outside of Diesel. You can specify where types should be imported from by doing: `table! { use @@ -1332,6 +1363,7 @@ queries or set `PIPES_AS_CONCAT` manually. when [boxed][boxed-0.11.0]. [select-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/fn.select.html + [boxed-0.11.0]: https://docs.rs/diesel/0.11.0/prelude/trait.BoxedDsl.html * Arrays containing null are now supported. `infer_schema!` will never infer an @@ -1344,6 +1376,7 @@ queries or set `PIPES_AS_CONCAT` manually. a join. [belongs-to-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/associations/trait.BelongsTo.html + [belonging-to-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/prelude/trait.BelongingToDsl.html#tymethod.belonging_to * Added support for the `rust-lang-deprecated/time` crate on PostgreSQL. To use @@ -1360,6 +1393,7 @@ queries or set `PIPES_AS_CONCAT` manually. return `NULL` when the table is empty. [max-0.11.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.max.html + [min-0.11.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.min.html * [`now`][now-0.11.0] can now be used as an expression of type `Timestamptz`. @@ -1672,6 +1706,7 @@ queries or set `PIPES_AS_CONCAT` manually. instead of `delete(users.find(user.id)).execute(&connection)` [associations-module]: https://docs.diesel.rs/diesel/associations/index.html + [syntex-split]: https://github.com/diesel-rs/diesel/commit/36b8801bf5e9594443743e6a7c62e29d3dce36b7 ### Fixed @@ -1982,67 +2017,131 @@ queries or set `PIPES_AS_CONCAT` manually. * Initial release [0.2.0]: https://github.com/diesel-rs/diesel/compare/v0.1.0...v0.2.0 + [0.3.0]: https://github.com/diesel-rs/diesel/compare/v0.2.0...v0.3.0 + [0.4.0]: https://github.com/diesel-rs/diesel/compare/v0.3.0...v0.4.0 + [0.4.1]: https://github.com/diesel-rs/diesel/compare/v0.4.0...v0.4.1 + [0.5.0]: https://github.com/diesel-rs/diesel/compare/v0.4.1...v0.5.0 + [0.5.1]: https://github.com/diesel-rs/diesel/compare/v0.5.0...v0.5.1 + [0.5.2]: https://github.com/diesel-rs/diesel/compare/v0.5.1...v0.5.2 + [0.5.3]: https://github.com/diesel-rs/diesel/compare/v0.5.2...v0.5.3 + [0.5.4]: https://github.com/diesel-rs/diesel/compare/v0.5.3...v0.5.4 + [0.6.0]: https://github.com/diesel-rs/diesel/compare/v0.5.4...v0.6.0 + [0.6.1]: https://github.com/diesel-rs/diesel/compare/v0.6.0...v0.6.1 + [0.7.0]: https://github.com/diesel-rs/diesel/compare/v0.6.1...v0.7.0 + [0.7.1]: https://github.com/diesel-rs/diesel/compare/v0.7.0...v0.7.1 + [0.7.2]: https://github.com/diesel-rs/diesel/compare/v0.7.1...v0.7.2 + [0.8.0]: https://github.com/diesel-rs/diesel/compare/v0.7.2...v0.8.0 + [0.8.1]: https://github.com/diesel-rs/diesel/compare/v0.8.0...v0.8.1 + [0.8.2]: https://github.com/diesel-rs/diesel/compare/v0.8.1...v0.8.2 + [0.9.0]: https://github.com/diesel-rs/diesel/compare/v0.8.2...v0.9.0 + [0.9.1]: https://github.com/diesel-rs/diesel/compare/v0.9.0...v0.9.1 + [0.10.0]: https://github.com/diesel-rs/diesel/compare/v0.9.1...v0.10.0 + [0.10.1]: https://github.com/diesel-rs/diesel/compare/v0.10.0...v0.10.1 + [0.11.0]: https://github.com/diesel-rs/diesel/compare/v0.10.1...v0.11.0 + [0.11.1]: https://github.com/diesel-rs/diesel/compare/v0.11.0...v0.11.1 + [0.11.2]: https://github.com/diesel-rs/diesel/compare/v0.11.1...v0.11.2 + [0.11.4]: https://github.com/diesel-rs/diesel/compare/v0.11.2...v0.11.4 + [0.12.0]: https://github.com/diesel-rs/diesel/compare/v0.11.4...v0.12.0 + [0.12.1]: https://github.com/diesel-rs/diesel/compare/v0.12.0...v0.12.1 + [0.13.0]: https://github.com/diesel-rs/diesel/compare/v0.12.1...v0.13.0 + [0.14.0]: https://github.com/diesel-rs/diesel/compare/v0.13.0...v0.14.0 + [0.14.1]: https://github.com/diesel-rs/diesel/compare/v0.14.0...v0.14.1 + [0.15.0]: https://github.com/diesel-rs/diesel/compare/v0.14.1...v0.15.0 + [0.15.1]: https://github.com/diesel-rs/diesel/compare/v0.15.0...v0.15.1 + [0.15.2]: https://github.com/diesel-rs/diesel/compare/v0.15.1...v0.15.2 + [0.16.0]: https://github.com/diesel-rs/diesel/compare/v0.15.2...v0.16.0 + [0.99.0]: https://github.com/diesel-rs/diesel/compare/v0.16.0...v0.99.0 + [0.99.1]: https://github.com/diesel-rs/diesel/compare/v0.99.0...v0.99.1 + [1.0.0]: https://github.com/diesel-rs/diesel/compare/v0.99.1...v1.0.0 + [1.1.0]: https://github.com/diesel-rs/diesel/compare/v1.0.0...v1.1.0 + [1.1.1]: https://github.com/diesel-rs/diesel/compare/v1.1.0...v1.1.1 + [1.1.2]: https://github.com/diesel-rs/diesel/compare/v1.1.1...v1.1.2 + [1.2.0]: https://github.com/diesel-rs/diesel/compare/v1.1.2...v1.2.0 + [1.2.1]: https://github.com/diesel-rs/diesel/compare/v1.2.0...v1.2.1 + [1.2.2]: https://github.com/diesel-rs/diesel/compare/v1.2.1...v1.2.2 + [1.3.0]: https://github.com/diesel-rs/diesel/compare/v1.2.2...v1.3.0 + [1.3.1]: https://github.com/diesel-rs/diesel/compare/v1.3.0...v1.3.1 + [1.3.2]: https://github.com/diesel-rs/diesel/compare/v1.3.1...v1.3.2 + [1.3.3]: https://github.com/diesel-rs/diesel/compare/v1.3.2...v1.3.3 + [1.4.0]: https://github.com/diesel-rs/diesel/compare/v1.3.0...v1.4.0 + [1.4.1]: https://github.com/diesel-rs/diesel/compare/v1.4.0...v1.4.1 + [1.4.2]: https://github.com/diesel-rs/diesel/compare/v1.4.1...v1.4.2 + [1.4.3]: https://github.com/diesel-rs/diesel/compare/v1.4.2...v1.4.3 + [1.4.4]: https://github.com/diesel-rs/diesel/compare/v1.4.3...v1.4.4 + [1.4.5]: https://github.com/diesel-rs/diesel/compare/v1.4.4...v1.4.5 + [1.4.6]: https://github.com/diesel-rs/diesel/compare/v1.4.5...v1.4.6 + [1.4.7]: https://github.com/diesel-rs/diesel/compare/v1.4.6...v1.4.7 + [1.4.8]: https://github.com/diesel-rs/diesel/compare/v1.4.7...v1.4.8 + [2.0.0 Rc0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0-rc0 + [2.0.0 Rc1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0-rc0...v2.0.0-rc1 + [2.0.0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0 + [2.0.1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.0.1 + [2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.1...v2.0.2 + [diesel_derives 2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...diesel_derives_v2.0.2 + [2.0.3]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...v2.0.3 + [2.0.4]: https://github.com/diesel-rs/diesel/compare/v.2.0.3...v2.0.4 + [2.1.0]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.1.0 From e2c39399ff81cd031e8e3181657343d9e8d84cd1 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 18:01:45 +0200 Subject: [PATCH 11/16] fmt clippy working tests --- diesel_cli/src/cli.rs | 4 ++- diesel_cli/src/config.rs | 26 ++++++++++++++++--- diesel_cli/tests/print_schema.rs | 2 +- .../diesel.toml | 3 ++- .../postgres/expected.snap | 4 +-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/diesel_cli/src/cli.rs b/diesel_cli/src/cli.rs index 43b269270738..06a84c9a3db7 100644 --- a/diesel_cli/src/cli.rs +++ b/diesel_cli/src/cli.rs @@ -308,9 +308,11 @@ pub fn build_cli() -> Command { .help("Generate SQL type definitions for types not provided by diesel"), ) .arg( - Arg::new("except-custom-type-definitions").action(ArgAction::Append) + Arg::new("except-custom-type-definitions") + .action(ArgAction::Append) .long("except-custom-type-definitions") .num_args(1..) + .action(ArgAction::Append) .help("A list of regexes to filter the custom types definitions generated") ) .arg( diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index 8cf3a37ea3e9..52d888cd4cdd 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -180,6 +180,12 @@ impl Config { matches, "sqlite-integer-primary-key-is-bigint", )?; + let except_custom_type_definitions_with_indices = + get_values_with_indices::>( + matches, + "except_custom_type_definitions", + )?; + for (key, boundary) in selected_schema_keys.values().cloned().zip( selected_schema_keys .keys() @@ -239,7 +245,7 @@ impl Config { _ => { return Err(crate::errors::Error::UnsupportedFeature(format!( "Invalid column sorting mode: {sorting}" - ))) + ))); } } } @@ -272,6 +278,12 @@ impl Config { print_schema.generate_missing_sql_type_definitions = Some(false) } + if let Some(except_rules) = &except_custom_type_definitions_with_indices { + if let Some(rules) = except_rules.range(boundary).nth(0) { + print_schema.except_custom_type_definitions = rules.1.clone(); + } + } + let custom_type_derives = custom_type_derives_with_indices .clone() .map(|v| v.range(boundary).map(|v| v.1.clone()).collect()) @@ -317,7 +329,7 @@ impl Config { _ => { return Err(crate::errors::Error::UnsupportedFeature(format!( "Invalid column sorting mode: {sorting}" - ))) + ))); } } } @@ -331,6 +343,14 @@ impl Config { config.import_types = Some(types); } + if let Some(except_rules) = matches.get_many("except-custom-type-definitions") { + let regexes: Vec = except_rules.cloned().collect(); + config.except_custom_type_definitions = regexes + .into_iter() + .map(|x| regex::Regex::new(&x).map(Into::into)) + .collect::, _>>()?; + } + if matches.get_flag("generate-custom-type-definitions") { config.generate_missing_sql_type_definitions = Some(false); } @@ -570,7 +590,7 @@ impl<'de> Deserialize<'de> for Filtering { return Err(de::Error::unknown_field( &key, &["only_tables", "except_tables"], - )) + )); } } } diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index 57b7ecab2fd3..ef83dc2652df 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -14,7 +14,7 @@ fn run_infer_schema_without_docs() { fn run_except_custom_type_definitions() { test_print_schema( "print_schema_except_custom_type_definitions", - vec!["--except-custom-type-definitions=MyType2"], + vec!["--except-custom-type-definitions", "MyType2"], ); } diff --git a/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml index 78497bb92c21..13befeea1e9b 100644 --- a/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml +++ b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/diesel.toml @@ -1,3 +1,4 @@ [print_schema] file = "src/schema.rs" -except_custom_sql_type_definitions = ["MyType2"] +except_custom_type_definitions = ["MyType2"] +custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] diff --git a/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap index 03a27a812030..3281decdd005 100644 --- a/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap +++ b/diesel_cli/tests/print_schema/print_schema_except_custom_type_definitions/postgres/expected.snap @@ -1,11 +1,11 @@ --- source: diesel_cli/tests/print_schema.rs -description: "Test: print_schema_custom_types_check_default_derives" +description: "Test: print_schema_except_custom_type_definitions" --- // @generated automatically by Diesel CLI. pub mod sql_types { - #[derive(diesel::sql_types::SqlType)] + #[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)] #[diesel(postgres_type(name = "my_type"))] pub struct MyType; } From 0b84d1d799dd9c4b36e928f10b8a4279c249a58c Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Thu, 25 Apr 2024 18:36:18 +0200 Subject: [PATCH 12/16] hyphens instead of underscores --- diesel_cli/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index 52d888cd4cdd..45e451ba6841 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -183,7 +183,7 @@ impl Config { let except_custom_type_definitions_with_indices = get_values_with_indices::>( matches, - "except_custom_type_definitions", + "except-custom-type-definitions", )?; for (key, boundary) in selected_schema_keys.values().cloned().zip( From a789a044b77a3e8054a9331eef26cf4d20bb2275 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Fri, 26 Apr 2024 10:56:01 +0200 Subject: [PATCH 13/16] Add feature gate for the except custom type deifinition --- diesel_cli/tests/print_schema.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/diesel_cli/tests/print_schema.rs b/diesel_cli/tests/print_schema.rs index ef83dc2652df..922198f505fe 100644 --- a/diesel_cli/tests/print_schema.rs +++ b/diesel_cli/tests/print_schema.rs @@ -11,6 +11,7 @@ fn run_infer_schema_without_docs() { } #[test] +#[cfg(feature = "postgres")] fn run_except_custom_type_definitions() { test_print_schema( "print_schema_except_custom_type_definitions", From 2b41ae1307bc6c37ae33e5a0ada99e1f467f3296 Mon Sep 17 00:00:00 2001 From: Samuel Batissou Date: Mon, 29 Apr 2024 12:22:06 +0200 Subject: [PATCH 14/16] revert changelog --- CHANGELOG.md | 157 ++++++++++----------------------------------------- 1 file changed, 29 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4d69c776899..312e021c558b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,22 +12,16 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's - skipped. +d* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions -* Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most - of the time, in turn enabling most queries to be written using just a `Selectable` derive. -* Added an optional `#[diesel(skip_insertion)]` field attribute to the `Insertable` derive macro, allowing fields which - map to generated columns to be skipped during insertion. +* Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. +* Added an optional `#[diesel(skip_insertion)]` field attribute to the `Insertable` derive macro, allowing fields which map to generated columns to be skipped during insertion. * Support for connection instrumentation. This allows to inspect any query run by your application * Logging in diesel-cli * Support for libsqlite3-sys 0.28 -* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to - use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` - attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)). -* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating - multiple schema.rs files +* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)). +* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating multiple schema.rs files * Add support for `COPY TO` and `COPY FROM` statements ### Changed @@ -43,11 +37,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to - support serialization/deserialization of SQLite databases to and from byte buffers. -* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by - calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope - with `sqlite3_free`. +* Added `serialize_database_to_buffer` and `deserialize_readonly_database_from_buffer` methods in `SqliteConnection` to support serialization/deserialization of SQLite databases to and from byte buffers. +* Added `SerializedDatabase` wrapper type for a serialized database that is dynamically allocated by calling `serialize_database_to_buffer`. This RAII wrapper deallocates the memory when it goes out of scope with `sqlite3_free`. * Added the `custom_type_derives` config option to customize the derives for SQL type definitions automatically generated by Diesel CLI. * Add a `#[derive(MultiConnection)]` proc-macro that lets you easily implement `diesel::Connection` @@ -64,12 +55,9 @@ Increasing the minimal supported Rust version will always be coupled at least wi ## Fixed -* Workaround the missing name resolution in rust-analyzer. This should fix type inference for some diesel queries. (It - remains broken for queries containing `.filter()`/`.inner_join()`/`.left_join()`. These require fixes in rust-analyzer - itself) +* Workaround the missing name resolution in rust-analyzer. This should fix type inference for some diesel queries. (It remains broken for queries containing `.filter()`/`.inner_join()`/`.left_join()`. These require fixes in rust-analyzer itself) * Fixed a bug that could lead to inserting null values instead of empty values for custom sqlite types -* Fixed a bug that could lead to an unexpected panic while providing an out of bounds bind for `sql_query` in the sqlite - backend +* Fixed a bug that could lead to an unexpected panic while providing an out of bounds bind for `sql_query` in the sqlite backend * Fixed some mysql backend specific impl being behind the `mysql` instead of the `mysql_backend` feature flag ## Added @@ -86,8 +74,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ## Fixed -* Fixed a bug with our transaction manager implementation that caused by marking transactions as broken which could be - recovered. +* Fixed a bug with our transaction manager implementation that caused by marking transactions as broken which could be recovered. * Fixed an issue with the combination of `BoxableExpression` and order clauses ## [2.0.2] 2022-10-11 @@ -100,8 +87,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Fixed -* Fixed an issue with `diesel_cli` generating incompatible type names for the `generate_missing_sql_type_definitions` - feature on PostgreSQL +* Fixed an issue with `diesel_cli` generating incompatible type names for the `generate_missing_sql_type_definitions` feature on PostgreSQL * Fixed an issue how `diesel_cli` handles sqlite urls while checking if a given database exists * Fixed an issue with `PgConnection` becoming unusable after hitting a database error in certain situations * Fixed an issue with diesel generating invalid SQL for certain `INSERT … ON CONFLICT` queries @@ -111,14 +97,9 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -* `MysqlConnection::establish` is able to initiate an SSL connection while specifying certificate roots. The database - URL should contain an `ssl_ca` parameter with a path pointing to the certificate - roots. [See docs](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-ca) if desired. +* `MysqlConnection::establish` is able to initiate an SSL connection while specifying certificate roots. The database URL should contain an `ssl_ca` parameter with a path pointing to the certificate roots. [See docs](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-ca) if desired. -* `MysqlConnection::establish` is able to initiate an SSL connection. The database URL should contain `ssl_mode` - parameter with a value of - the [MySQL client command option `--ssl-mode`](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode) - if desired. +* `MysqlConnection::establish` is able to initiate an SSL connection. The database URL should contain `ssl_mode` parameter with a value of the [MySQL client command option `--ssl-mode`](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode) if desired. * `Connection` and `SimpleConnection` traits are implemented for a broader range of `r2d2::PooledConnection` types when the `r2d2` feature is enabled. @@ -176,11 +157,9 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Added support for SQL functions without arguments for SQLite. -* Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It's - possible to disable this behavior via the `generate_missing_sql_type_definitions` config option. +* Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It's possible to disable this behavior via the `generate_missing_sql_type_definitions` config option. -* Added an option to `#[derive(Insertable)]` that let you insert `NULL` values instead of `DEFAULT` values - for `Option` +* Added an option to `#[derive(Insertable)]` that let you insert `NULL` values instead of `DEFAULT` values for `Option` * Added support for all the derive attributes being inside `#[diesel(...)]` @@ -235,7 +214,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi should check the relevant section of [the migration guide][2-0-migration]. [backend-2-0-0]: http://docs.diesel.rs/diesel/backend/trait.Backend.html - [raw-value-2-0-0]: http://docs.diesel.rs/diesel/backend/type.RawValue.html * The type metadata for MySQL has been changed to include sign information. If @@ -269,8 +247,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi introduce a wild card match instead. * `FromSql::from_sql` is changed to construct value from non nullable database values. - To construct a rust value for nullable values use the new `FromSql::from_nullable_sql` - method instead. + To construct a rust value for nullable values use the new `FromSql::from_nullable_sql` + method instead. * Custom sql types are now required to implement the new `SqlType` trait. Diesel will automatically create implementations of that trait for all types having a `#[derive(SqlType)]` @@ -318,9 +296,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi * The sqlite backend now uses a single batch insert statement if there are now default values present in the values clause -* The MySQL connection is using the CLIENT_FOUND_ROWS from now on. This means that updating rows without changing any - values will return the number of matched rows (like most other SQL servers do), as opposed to the number of changed - rows. +* The MySQL connection is using the CLIENT_FOUND_ROWS from now on. This means that updating rows without changing any values will return the number of matched rows (like most other SQL servers do), as opposed to the number of changed rows. * The definition of `ToSql::to_sql` and `QueryFragment::walk_ast` has changed to allow serializing values without copying the value itself. This is useful for database backends like sqlite where you can directly share a buffer @@ -328,10 +304,10 @@ Increasing the minimal supported Rust version will always be coupled at least wi all cases. * The `PIPES_AS_CONCAT` sql_mode is no longer set - by default. This setting requires a modification to MySQL query parsing that is - not supported by certain systems (such as Vitess). If you are using MySQL and - executing raw queries with the `||` operator, you will need to rewrite your - queries or set `PIPES_AS_CONCAT` manually. +by default. This setting requires a modification to MySQL query parsing that is +not supported by certain systems (such as Vitess). If you are using MySQL and +executing raw queries with the `||` operator, you will need to rewrite your +queries or set `PIPES_AS_CONCAT` manually. ### Fixed @@ -378,8 +354,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Implementations of custom SQLite SQL functions now check for panics -* `diesel print-schema` now generates `Array>` rather than `Array` for Postgres Array types. Existence - of +* `diesel print-schema` now generates `Array>` rather than `Array` for Postgres Array types. Existence of `NULL` values in database arrays would previously result in deserialization errors. Non-nullable arrays are now opt in (by schema patching). @@ -395,7 +370,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi Please use `diesel::upsert` instead. * `diesel::dsl::any` and `diesel::dsl::all` are now deprecated in - favour of `ExpressionMethods::eq_any()` and `ExpressionMethods::ne_all()` + favour of `ExpressionMethods::eq_any()` and `ExpressionMethods::ne_all()` + [2-0-migration]: https://github.com/diesel-rs/diesel/blob/master/guide_drafts/migration_guide.md @@ -403,8 +379,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Fixed -* Fixed a incompatibly between `diesel` and `diesel_migrations` when building both crates with cargos - new `resolver = "2"` enabled. This change ensures compatibility with the upcoming 2021 rust edition. +* Fixed a incompatibly between `diesel` and `diesel_migrations` when building both crates with cargos new `resolver = "2"` enabled. This change ensures compatibility with the upcoming 2021 rust edition. ## [1.4.7] - 2021-06-08 @@ -449,6 +424,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Fixed issue where rustdoc failed to build the documentation * `diesel_derives` and `diesel_migrations` are updated to syn 1.0 + ## [1.4.2] - 2019-03-19 ### Fixed @@ -499,7 +475,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi example, if one of the fields has the type `Cow<'a, str>`). To define an association to such a type, write `#[belongs_to(parent = "User<'_>")]` -* `Nullable` now supports `ilike` expression on in PostgreSQL. +* `Nullable` now supports `ilike` expression on in PostgreSQL. * `diesel_manage_updated_at('table_name')` is now available on SQLite. This function can be called in your migrations to create a trigger which @@ -670,7 +646,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi [`SqliteConnection::exclusive_transaction`] for details [`SqliteConnection::immediate_transaction`]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.immediate_transaction - [`SqliteConnection::exclusive_transaction`]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.exclusive_transaction * Tables with more than 56 columns are now supported by enabling the @@ -832,7 +807,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi `Cargo.toml`. [rust-deprecation-bug-1]: https://github.com/rust-lang/rust/issues/47236 - [rust-deprecation-bug-2]: https://github.com/rust-lang/rust/issues/47237 * Deprecated `impl_query_id!` in favor of `#[derive(QueryId)]` @@ -1121,7 +1095,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi `1`. [bigdecimal-0.16.0]: https://crates.io/crates/bigdecimal - [range-0.16.0]: https://docs.diesel.rs/diesel/pg/types/sql_types/struct.Range.html ## [0.15.2] - 2017-07-28 @@ -1190,11 +1163,8 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Added the [`insert_default_values`][insert-default-0.14.0] function. [pg-network-0.14.0]: https://www.postgresql.org/docs/9.6/static/datatype-net-types.html - [not-0.14.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.not.html - [insert-default-0.14.0]: https://docs.diesel.rs/diesel/fn.insert_default_values.html - [bigdecimal-0.14.0]: https://crates.io/crates/bigdecimal * Added `diesel_prefix_operator!` which behaves identically to @@ -1285,8 +1255,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi [pg-money-0.12.0]: https://www.postgresql.org/docs/9.6/static/datatype-money.html -* Diesel CLI: Added `db` as an alias for `database`, so you can now write `diesel db setup` (which is almost 40% - faster!). +* Diesel CLI: Added `db` as an alias for `database`, so you can now write `diesel db setup` (which is almost 40% faster!). * The `table!` macro now allows you to use types from crates outside of Diesel. You can specify where types should be imported from by doing: `table! { use @@ -1363,7 +1332,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi when [boxed][boxed-0.11.0]. [select-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/fn.select.html - [boxed-0.11.0]: https://docs.rs/diesel/0.11.0/prelude/trait.BoxedDsl.html * Arrays containing null are now supported. `infer_schema!` will never infer an @@ -1376,7 +1344,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi a join. [belongs-to-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/associations/trait.BelongsTo.html - [belonging-to-0.11.0]: https://docs.rs/diesel/0.11.0/diesel/prelude/trait.BelongingToDsl.html#tymethod.belonging_to * Added support for the `rust-lang-deprecated/time` crate on PostgreSQL. To use @@ -1393,7 +1360,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi return `NULL` when the table is empty. [max-0.11.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.max.html - [min-0.11.0]: https://docs.diesel.rs/diesel/expression/dsl/fn.min.html * [`now`][now-0.11.0] can now be used as an expression of type `Timestamptz`. @@ -1706,7 +1672,6 @@ Increasing the minimal supported Rust version will always be coupled at least wi instead of `delete(users.find(user.id)).execute(&connection)` [associations-module]: https://docs.diesel.rs/diesel/associations/index.html - [syntex-split]: https://github.com/diesel-rs/diesel/commit/36b8801bf5e9594443743e6a7c62e29d3dce36b7 ### Fixed @@ -2017,131 +1982,67 @@ Increasing the minimal supported Rust version will always be coupled at least wi * Initial release [0.2.0]: https://github.com/diesel-rs/diesel/compare/v0.1.0...v0.2.0 - [0.3.0]: https://github.com/diesel-rs/diesel/compare/v0.2.0...v0.3.0 - [0.4.0]: https://github.com/diesel-rs/diesel/compare/v0.3.0...v0.4.0 - [0.4.1]: https://github.com/diesel-rs/diesel/compare/v0.4.0...v0.4.1 - [0.5.0]: https://github.com/diesel-rs/diesel/compare/v0.4.1...v0.5.0 - [0.5.1]: https://github.com/diesel-rs/diesel/compare/v0.5.0...v0.5.1 - [0.5.2]: https://github.com/diesel-rs/diesel/compare/v0.5.1...v0.5.2 - [0.5.3]: https://github.com/diesel-rs/diesel/compare/v0.5.2...v0.5.3 - [0.5.4]: https://github.com/diesel-rs/diesel/compare/v0.5.3...v0.5.4 - [0.6.0]: https://github.com/diesel-rs/diesel/compare/v0.5.4...v0.6.0 - [0.6.1]: https://github.com/diesel-rs/diesel/compare/v0.6.0...v0.6.1 - [0.7.0]: https://github.com/diesel-rs/diesel/compare/v0.6.1...v0.7.0 - [0.7.1]: https://github.com/diesel-rs/diesel/compare/v0.7.0...v0.7.1 - [0.7.2]: https://github.com/diesel-rs/diesel/compare/v0.7.1...v0.7.2 - [0.8.0]: https://github.com/diesel-rs/diesel/compare/v0.7.2...v0.8.0 - [0.8.1]: https://github.com/diesel-rs/diesel/compare/v0.8.0...v0.8.1 - [0.8.2]: https://github.com/diesel-rs/diesel/compare/v0.8.1...v0.8.2 - [0.9.0]: https://github.com/diesel-rs/diesel/compare/v0.8.2...v0.9.0 - [0.9.1]: https://github.com/diesel-rs/diesel/compare/v0.9.0...v0.9.1 - [0.10.0]: https://github.com/diesel-rs/diesel/compare/v0.9.1...v0.10.0 - [0.10.1]: https://github.com/diesel-rs/diesel/compare/v0.10.0...v0.10.1 - [0.11.0]: https://github.com/diesel-rs/diesel/compare/v0.10.1...v0.11.0 - [0.11.1]: https://github.com/diesel-rs/diesel/compare/v0.11.0...v0.11.1 - [0.11.2]: https://github.com/diesel-rs/diesel/compare/v0.11.1...v0.11.2 - [0.11.4]: https://github.com/diesel-rs/diesel/compare/v0.11.2...v0.11.4 - [0.12.0]: https://github.com/diesel-rs/diesel/compare/v0.11.4...v0.12.0 - [0.12.1]: https://github.com/diesel-rs/diesel/compare/v0.12.0...v0.12.1 - [0.13.0]: https://github.com/diesel-rs/diesel/compare/v0.12.1...v0.13.0 - [0.14.0]: https://github.com/diesel-rs/diesel/compare/v0.13.0...v0.14.0 - [0.14.1]: https://github.com/diesel-rs/diesel/compare/v0.14.0...v0.14.1 - [0.15.0]: https://github.com/diesel-rs/diesel/compare/v0.14.1...v0.15.0 - [0.15.1]: https://github.com/diesel-rs/diesel/compare/v0.15.0...v0.15.1 - [0.15.2]: https://github.com/diesel-rs/diesel/compare/v0.15.1...v0.15.2 - [0.16.0]: https://github.com/diesel-rs/diesel/compare/v0.15.2...v0.16.0 - [0.99.0]: https://github.com/diesel-rs/diesel/compare/v0.16.0...v0.99.0 - [0.99.1]: https://github.com/diesel-rs/diesel/compare/v0.99.0...v0.99.1 - [1.0.0]: https://github.com/diesel-rs/diesel/compare/v0.99.1...v1.0.0 - [1.1.0]: https://github.com/diesel-rs/diesel/compare/v1.0.0...v1.1.0 - [1.1.1]: https://github.com/diesel-rs/diesel/compare/v1.1.0...v1.1.1 - [1.1.2]: https://github.com/diesel-rs/diesel/compare/v1.1.1...v1.1.2 - [1.2.0]: https://github.com/diesel-rs/diesel/compare/v1.1.2...v1.2.0 - [1.2.1]: https://github.com/diesel-rs/diesel/compare/v1.2.0...v1.2.1 - [1.2.2]: https://github.com/diesel-rs/diesel/compare/v1.2.1...v1.2.2 - [1.3.0]: https://github.com/diesel-rs/diesel/compare/v1.2.2...v1.3.0 - [1.3.1]: https://github.com/diesel-rs/diesel/compare/v1.3.0...v1.3.1 - [1.3.2]: https://github.com/diesel-rs/diesel/compare/v1.3.1...v1.3.2 - [1.3.3]: https://github.com/diesel-rs/diesel/compare/v1.3.2...v1.3.3 - [1.4.0]: https://github.com/diesel-rs/diesel/compare/v1.3.0...v1.4.0 - [1.4.1]: https://github.com/diesel-rs/diesel/compare/v1.4.0...v1.4.1 - [1.4.2]: https://github.com/diesel-rs/diesel/compare/v1.4.1...v1.4.2 - [1.4.3]: https://github.com/diesel-rs/diesel/compare/v1.4.2...v1.4.3 - [1.4.4]: https://github.com/diesel-rs/diesel/compare/v1.4.3...v1.4.4 - [1.4.5]: https://github.com/diesel-rs/diesel/compare/v1.4.4...v1.4.5 - [1.4.6]: https://github.com/diesel-rs/diesel/compare/v1.4.5...v1.4.6 - [1.4.7]: https://github.com/diesel-rs/diesel/compare/v1.4.6...v1.4.7 - [1.4.8]: https://github.com/diesel-rs/diesel/compare/v1.4.7...v1.4.8 - [2.0.0 Rc0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0-rc0 - [2.0.0 Rc1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0-rc0...v2.0.0-rc1 - [2.0.0]: https://github.com/diesel-rs/diesel/compare/v.1.4.0...v2.0.0 - [2.0.1]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.0.1 - [2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.1...v2.0.2 - [diesel_derives 2.0.2]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...diesel_derives_v2.0.2 - [2.0.3]: https://github.com/diesel-rs/diesel/compare/v.2.0.2...v2.0.3 - [2.0.4]: https://github.com/diesel-rs/diesel/compare/v.2.0.3...v2.0.4 - [2.1.0]: https://github.com/diesel-rs/diesel/compare/v.2.0.0...v2.1.0 From 496e076809f299bef4cd6ea2fd2ddf46c18f6dea Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Mon, 29 Apr 2024 15:03:00 +0000 Subject: [PATCH 15/16] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 312e021c558b..0bf5be124b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi ### Added -d* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped. +* Support `[print_schema] exclude_custom_type_definitions=["Vector"]`. If a `custom type` matches one element on the list it's skipped. * Added automatic usage of all sqlite `rowid` aliases when no explicit primary key is defined for `print-schema` * Added a `#[dsl::auto_type]` attribute macro, allowing to infer type of query fragment functions * Added the same type inference on `Selectable` derives, which allows skipping specifying `select_expression_type` most of the time, in turn enabling most queries to be written using just a `Selectable` derive. From 1a7dabb965af77ca1d97d96fcd5e662e0125474b Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 3 May 2024 12:49:11 +0200 Subject: [PATCH 16/16] Another clippy fix after rebasing --- diesel_cli/src/config.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index 45e451ba6841..346d0288bf23 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -280,7 +280,9 @@ impl Config { if let Some(except_rules) = &except_custom_type_definitions_with_indices { if let Some(rules) = except_rules.range(boundary).nth(0) { - print_schema.except_custom_type_definitions = rules.1.clone(); + print_schema + .except_custom_type_definitions + .clone_from(rules.1); } }