From dc34d27e5c9938ba3fa811c1a2f9d1266e4a2119 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 2 Nov 2023 15:49:41 +0100 Subject: [PATCH 1/5] fix(code): change serde derives to use "serde::" instead of requiring import re https://github.com/Wulf/dsync/pull/104/commits/c3dbfaa00d116fb133da09d299b42dc4b112d831 --- src/code.rs | 8 ++------ test/autogenerated_all/models/todos/generated.rs | 7 +++---- test/autogenerated_attributes/models/todos/generated.rs | 9 ++++----- .../autogenerated_primary_keys/models/todos/generated.rs | 9 ++++----- test/cleanup_generated_content/models/todos/generated.rs | 9 ++++----- test/create_update_str_cow/models/todos/generated.rs | 9 ++++----- test/create_update_str_str/models/todos/generated.rs | 9 ++++----- .../models/tableA/generated.rs | 7 +++---- .../models/tableB/generated.rs | 9 ++++----- test/custom_model_path/models/tableA/generated.rs | 7 +++---- test/custom_model_path/models/tableB/generated.rs | 9 ++++----- test/manual_primary_keys/models/todos/generated.rs | 7 +++---- test/multiple_primary_keys/models/users/generated.rs | 9 ++++----- test/no_default_features/models/todos/generated.rs | 9 ++++----- test/once_common_structs/models/common.rs | 2 +- test/once_common_structs/models/table1/generated.rs | 3 +-- test/once_common_structs/models/table2/generated.rs | 3 +-- .../models/common.rs | 2 +- .../models/table1/generated.rs | 3 +-- .../models/table2/generated.rs | 3 +-- .../models/common.rs | 2 +- .../models/table1.rs | 3 +-- .../models/table2.rs | 3 +-- test/once_connection_type/models/table1/generated.rs | 5 ++--- test/once_connection_type/models/table2/generated.rs | 5 ++--- test/readonly/models/normal/generated.rs | 9 ++++----- test/readonly/models/prefixTable/generated.rs | 5 ++--- test/readonly/models/prefixTableSuffix/generated.rs | 5 ++--- test/readonly/models/tableSuffix/generated.rs | 5 ++--- test/simple_table/models/todos/generated.rs | 9 ++++----- test/simple_table_async/models/todos/generated.rs | 9 ++++----- .../models/todos/generated.rs | 9 ++++----- test/simple_table_no_crud/models/todos/generated.rs | 7 +++---- test/single_model_file/models/table1.rs | 5 ++--- test/single_model_file/models/table2.rs | 5 ++--- test/use_statements/models/fang_tasks/generated.rs | 9 ++++----- 36 files changed, 96 insertions(+), 132 deletions(-) diff --git a/src/code.rs b/src/code.rs index e982a36f..400165f4 100644 --- a/src/code.rs +++ b/src/code.rs @@ -119,8 +119,8 @@ pub mod derives { pub const CLONE: &str = "Clone"; pub const QUERYABLE: &str = "Queryable"; pub const INSERTABLE: &str = "Insertable"; - pub const SERIALIZE: &str = "Serialize"; - pub const DESERIALIZE: &str = "Deserialize"; + pub const SERIALIZE: &str = "serde::Serialize"; + pub const DESERIALIZE: &str = "serde::Deserialize"; pub const ASCHANGESET: &str = "AsChangeset"; pub const SELECTABLE: &str = "Selectable"; pub const IDENTIFIABLE: &str = "Identifiable"; @@ -628,10 +628,6 @@ fn build_imports(table: &ParsedTableMacro, config: &GenerationConfig) -> String // no "::" because that is already included in the schema_path imports_vec.push(format!("use {}*;", config.schema_path)); - if table_options.get_serde() { - imports_vec.push("use serde::{Deserialize, Serialize};".into()); - }; - if table_options.get_fns() { imports_vec.push("use diesel::QueryResult;".into()); }; diff --git a/test/autogenerated_all/models/todos/generated.rs b/test/autogenerated_all/models/todos/generated.rs index 2f60e341..a91374f3 100644 --- a/test/autogenerated_all/models/todos/generated.rs +++ b/test/autogenerated_all/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct Todos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `created_at` @@ -26,7 +25,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/autogenerated_attributes/models/todos/generated.rs b/test/autogenerated_attributes/models/todos/generated.rs index 91b8f145..21a2097f 100644 --- a/test/autogenerated_attributes/models/todos/generated.rs +++ b/test/autogenerated_attributes/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `id` @@ -26,7 +25,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `created_at` @@ -34,7 +33,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/autogenerated_primary_keys/models/todos/generated.rs b/test/autogenerated_primary_keys/models/todos/generated.rs index 21696217..53a77429 100644 --- a/test/autogenerated_primary_keys/models/todos/generated.rs +++ b/test/autogenerated_primary_keys/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `text` @@ -26,7 +25,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `text` @@ -34,7 +33,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/cleanup_generated_content/models/todos/generated.rs b/test/cleanup_generated_content/models/todos/generated.rs index 9b764adc..78f6f816 100644 --- a/test/cleanup_generated_content/models/todos/generated.rs +++ b/test/cleanup_generated_content/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -24,7 +23,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `id` @@ -36,7 +35,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `text` @@ -50,7 +49,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/create_update_str_cow/models/todos/generated.rs b/test/create_update_str_cow/models/todos/generated.rs index ba960429..37144f52 100644 --- a/test/create_update_str_cow/models/todos/generated.rs +++ b/test/create_update_str_cow/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(text))] pub struct Todos { /// Field representing column `text` @@ -22,7 +21,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos<'a> { /// Field representing column `text` @@ -36,7 +35,7 @@ pub struct CreateTodos<'a> { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos<'a> { /// Field representing column `text_nullable` @@ -48,7 +47,7 @@ pub struct UpdateTodos<'a> { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/create_update_str_str/models/todos/generated.rs b/test/create_update_str_str/models/todos/generated.rs index 928ed0a3..3528fdaf 100644 --- a/test/create_update_str_str/models/todos/generated.rs +++ b/test/create_update_str_str/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(text))] pub struct Todos { /// Field representing column `text` @@ -22,7 +21,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos<'a> { /// Field representing column `text` @@ -36,7 +35,7 @@ pub struct CreateTodos<'a> { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos<'a> { /// Field representing column `text_nullable` @@ -48,7 +47,7 @@ pub struct UpdateTodos<'a> { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/custom_model_and_schema_path/models/tableA/generated.rs b/test/custom_model_and_schema_path/models/tableA/generated.rs index 7e5af8e9..a042daa5 100644 --- a/test/custom_model_and_schema_path/models/tableA/generated.rs +++ b/test/custom_model_and_schema_path/models/tableA/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::data::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=tableA, primary_key(_id))] pub struct TableA { /// Field representing column `_id` @@ -16,7 +15,7 @@ pub struct TableA { } /// Create Struct for a row in table `tableA` for [`TableA`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=tableA)] pub struct CreateTableA { /// Field representing column `_id` @@ -24,7 +23,7 @@ pub struct CreateTableA { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/custom_model_and_schema_path/models/tableB/generated.rs b/test/custom_model_and_schema_path/models/tableB/generated.rs index 1c810be4..a08f277f 100644 --- a/test/custom_model_and_schema_path/models/tableB/generated.rs +++ b/test/custom_model_and_schema_path/models/tableB/generated.rs @@ -3,13 +3,12 @@ use crate::diesel::*; use crate::data::models::table_a::TableA; use crate::data::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] #[diesel(table_name=tableB, primary_key(_id), belongs_to(TableA, foreign_key=link))] pub struct TableB { /// Field representing column `_id` @@ -19,7 +18,7 @@ pub struct TableB { } /// Create Struct for a row in table `tableB` for [`TableB`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=tableB)] pub struct CreateTableB { /// Field representing column `_id` @@ -29,7 +28,7 @@ pub struct CreateTableB { } /// Update Struct for a row in table `tableB` for [`TableB`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=tableB)] pub struct UpdateTableB { /// Field representing column `link` @@ -37,7 +36,7 @@ pub struct UpdateTableB { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/tableA/generated.rs index c58bf98d..21bac314 100644 --- a/test/custom_model_path/models/tableA/generated.rs +++ b/test/custom_model_path/models/tableA/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=tableA, primary_key(_id))] pub struct TableA { /// Field representing column `_id` @@ -16,7 +15,7 @@ pub struct TableA { } /// Create Struct for a row in table `tableA` for [`TableA`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=tableA)] pub struct CreateTableA { /// Field representing column `_id` @@ -24,7 +23,7 @@ pub struct CreateTableA { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/tableB/generated.rs index 5299feaa..232daf2b 100644 --- a/test/custom_model_path/models/tableB/generated.rs +++ b/test/custom_model_path/models/tableB/generated.rs @@ -3,13 +3,12 @@ use crate::diesel::*; use crate::data::models::table_a::TableA; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] #[diesel(table_name=tableB, primary_key(_id), belongs_to(TableA, foreign_key=link))] pub struct TableB { /// Field representing column `_id` @@ -19,7 +18,7 @@ pub struct TableB { } /// Create Struct for a row in table `tableB` for [`TableB`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=tableB)] pub struct CreateTableB { /// Field representing column `_id` @@ -29,7 +28,7 @@ pub struct CreateTableB { } /// Update Struct for a row in table `tableB` for [`TableB`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=tableB)] pub struct UpdateTableB { /// Field representing column `link` @@ -37,7 +36,7 @@ pub struct UpdateTableB { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/manual_primary_keys/models/todos/generated.rs b/test/manual_primary_keys/models/todos/generated.rs index 4bb880e7..756dee7d 100644 --- a/test/manual_primary_keys/models/todos/generated.rs +++ b/test/manual_primary_keys/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -16,7 +15,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `id` @@ -24,7 +23,7 @@ pub struct CreateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/multiple_primary_keys/models/users/generated.rs b/test/multiple_primary_keys/models/users/generated.rs index 523e61e4..257e9f21 100644 --- a/test/multiple_primary_keys/models/users/generated.rs +++ b/test/multiple_primary_keys/models/users/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `users` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=users, primary_key(name,address))] pub struct Users { /// Field representing column `name` @@ -20,7 +19,7 @@ pub struct Users { } /// Create Struct for a row in table `users` for [`Users`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=users)] pub struct CreateUsers { /// Field representing column `name` @@ -32,7 +31,7 @@ pub struct CreateUsers { } /// Update Struct for a row in table `users` for [`Users`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=users)] pub struct UpdateUsers { /// Field representing column `secret` @@ -40,7 +39,7 @@ pub struct UpdateUsers { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/no_default_features/models/todos/generated.rs b/test/no_default_features/models/todos/generated.rs index 4ce3fcbb..dea03000 100644 --- a/test/no_default_features/models/todos/generated.rs +++ b/test/no_default_features/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -30,7 +29,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `unsigned` @@ -46,7 +45,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `unsigned` @@ -66,7 +65,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/once_common_structs/models/common.rs b/test/once_common_structs/models/common.rs index a892e81e..c74d3bb7 100644 --- a/test/once_common_structs/models/common.rs +++ b/test/once_common_structs/models/common.rs @@ -1,6 +1,6 @@ /* @generated and managed by dsync */ /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/once_common_structs/models/table1/generated.rs b/test/once_common_structs/models/table1/generated.rs index dc16d78b..c83e70a5 100644 --- a/test/once_common_structs/models/table1/generated.rs +++ b/test/once_common_structs/models/table1/generated.rs @@ -2,14 +2,13 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table1, primary_key(id))] pub struct Table1 { /// Field representing column `id` diff --git a/test/once_common_structs/models/table2/generated.rs b/test/once_common_structs/models/table2/generated.rs index c6387a00..980dae85 100644 --- a/test/once_common_structs/models/table2/generated.rs +++ b/test/once_common_structs/models/table2/generated.rs @@ -2,14 +2,13 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table2, primary_key(id))] pub struct Table2 { /// Field representing column `id` diff --git a/test/once_common_structs_once_connection_type/models/common.rs b/test/once_common_structs_once_connection_type/models/common.rs index dcec353a..781b2c5e 100644 --- a/test/once_common_structs_once_connection_type/models/common.rs +++ b/test/once_common_structs_once_connection_type/models/common.rs @@ -1,6 +1,6 @@ /* @generated and managed by dsync */ /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/once_common_structs_once_connection_type/models/table1/generated.rs b/test/once_common_structs_once_connection_type/models/table1/generated.rs index b2c39ed7..b83060fc 100644 --- a/test/once_common_structs_once_connection_type/models/table1/generated.rs +++ b/test/once_common_structs_once_connection_type/models/table1/generated.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table1` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table1, primary_key(id))] pub struct Table1 { /// Field representing column `id` diff --git a/test/once_common_structs_once_connection_type/models/table2/generated.rs b/test/once_common_structs_once_connection_type/models/table2/generated.rs index 836e7e51..8b8a87f4 100644 --- a/test/once_common_structs_once_connection_type/models/table2/generated.rs +++ b/test/once_common_structs_once_connection_type/models/table2/generated.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table2` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table2, primary_key(id))] pub struct Table2 { /// Field representing column `id` diff --git a/test/once_common_structs_once_connection_type_single_file/models/common.rs b/test/once_common_structs_once_connection_type_single_file/models/common.rs index dcec353a..781b2c5e 100644 --- a/test/once_common_structs_once_connection_type_single_file/models/common.rs +++ b/test/once_common_structs_once_connection_type_single_file/models/common.rs @@ -1,6 +1,6 @@ /* @generated and managed by dsync */ /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/once_common_structs_once_connection_type_single_file/models/table1.rs b/test/once_common_structs_once_connection_type_single_file/models/table1.rs index b2c39ed7..b83060fc 100644 --- a/test/once_common_structs_once_connection_type_single_file/models/table1.rs +++ b/test/once_common_structs_once_connection_type_single_file/models/table1.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table1` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table1, primary_key(id))] pub struct Table1 { /// Field representing column `id` diff --git a/test/once_common_structs_once_connection_type_single_file/models/table2.rs b/test/once_common_structs_once_connection_type_single_file/models/table2.rs index 836e7e51..8b8a87f4 100644 --- a/test/once_common_structs_once_connection_type_single_file/models/table2.rs +++ b/test/once_common_structs_once_connection_type_single_file/models/table2.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table2` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table2, primary_key(id))] pub struct Table2 { /// Field representing column `id` diff --git a/test/once_connection_type/models/table1/generated.rs b/test/once_connection_type/models/table1/generated.rs index cad4d35d..874960f9 100644 --- a/test/once_connection_type/models/table1/generated.rs +++ b/test/once_connection_type/models/table1/generated.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table1` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table1, primary_key(id))] pub struct Table1 { /// Field representing column `id` @@ -15,7 +14,7 @@ pub struct Table1 { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/once_connection_type/models/table2/generated.rs b/test/once_connection_type/models/table2/generated.rs index cca41e39..72359327 100644 --- a/test/once_connection_type/models/table2/generated.rs +++ b/test/once_connection_type/models/table2/generated.rs @@ -2,12 +2,11 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; use crate::models::common::*; /// Struct representing a row in table `table2` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table2, primary_key(id))] pub struct Table2 { /// Field representing column `id` @@ -15,7 +14,7 @@ pub struct Table2 { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/readonly/models/normal/generated.rs b/test/readonly/models/normal/generated.rs index 783f76f7..b253ece0 100644 --- a/test/readonly/models/normal/generated.rs +++ b/test/readonly/models/normal/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `normal` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=normal, primary_key(id))] pub struct Normal { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct Normal { } /// Create Struct for a row in table `normal` for [`Normal`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=normal)] pub struct CreateNormal { /// Field representing column `testprop` @@ -26,7 +25,7 @@ pub struct CreateNormal { } /// Update Struct for a row in table `normal` for [`Normal`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=normal)] pub struct UpdateNormal { /// Field representing column `testprop` @@ -34,7 +33,7 @@ pub struct UpdateNormal { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/readonly/models/prefixTable/generated.rs b/test/readonly/models/prefixTable/generated.rs index 22cf809b..85950002 100644 --- a/test/readonly/models/prefixTable/generated.rs +++ b/test/readonly/models/prefixTable/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTable` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=prefixTable, primary_key(id))] pub struct PrefixTable { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct PrefixTable { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/readonly/models/prefixTableSuffix/generated.rs b/test/readonly/models/prefixTableSuffix/generated.rs index 49434037..ed8bc722 100644 --- a/test/readonly/models/prefixTableSuffix/generated.rs +++ b/test/readonly/models/prefixTableSuffix/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTableSuffix` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=prefixTableSuffix, primary_key(id))] pub struct PrefixTableSuffix { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct PrefixTableSuffix { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/readonly/models/tableSuffix/generated.rs b/test/readonly/models/tableSuffix/generated.rs index 02563175..20212f0f 100644 --- a/test/readonly/models/tableSuffix/generated.rs +++ b/test/readonly/models/tableSuffix/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableSuffix` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=tableSuffix, primary_key(id))] pub struct TableSuffix { /// Field representing column `id` @@ -18,7 +17,7 @@ pub struct TableSuffix { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index 66042316..a51b1d99 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -30,7 +29,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `unsigned` @@ -46,7 +45,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `unsigned` @@ -66,7 +65,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/simple_table_async/models/todos/generated.rs b/test/simple_table_async/models/todos/generated.rs index 9e420c34..aaa51474 100644 --- a/test/simple_table_async/models/todos/generated.rs +++ b/test/simple_table_async/models/todos/generated.rs @@ -3,13 +3,12 @@ use crate::diesel::*; use diesel_async::RunQueryDsl; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel_async::pooled_connection::deadpool::Object; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -27,7 +26,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `unsigned` @@ -39,7 +38,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `unsigned` @@ -55,7 +54,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/simple_table_custom_schema_path/models/todos/generated.rs b/test/simple_table_custom_schema_path/models/todos/generated.rs index e7977d4f..52a37014 100644 --- a/test/simple_table_custom_schema_path/models/todos/generated.rs +++ b/test/simple_table_custom_schema_path/models/todos/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::data::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -26,7 +25,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `unsigned` @@ -38,7 +37,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `unsigned` @@ -54,7 +53,7 @@ pub struct UpdateTodos { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/simple_table_no_crud/models/todos/generated.rs b/test/simple_table_no_crud/models/todos/generated.rs index 18086b05..9694f4dd 100644 --- a/test/simple_table_no_crud/models/todos/generated.rs +++ b/test/simple_table_no_crud/models/todos/generated.rs @@ -2,10 +2,9 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; /// Struct representing a row in table `todos` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=todos, primary_key(id))] pub struct Todos { /// Field representing column `id` @@ -23,7 +22,7 @@ pub struct Todos { } /// Create Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=todos)] pub struct CreateTodos { /// Field representing column `unsigned` @@ -35,7 +34,7 @@ pub struct CreateTodos { } /// Update Struct for a row in table `todos` for [`Todos`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=todos)] pub struct UpdateTodos { /// Field representing column `unsigned` diff --git a/test/single_model_file/models/table1.rs b/test/single_model_file/models/table1.rs index 26a3f5a1..b4a8f174 100644 --- a/test/single_model_file/models/table1.rs +++ b/test/single_model_file/models/table1.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table1, primary_key(id))] pub struct Table1 { /// Field representing column `id` @@ -16,7 +15,7 @@ pub struct Table1 { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/single_model_file/models/table2.rs b/test/single_model_file/models/table2.rs index dd69561c..f52ef188 100644 --- a/test/single_model_file/models/table2.rs +++ b/test/single_model_file/models/table2.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=table2, primary_key(id))] pub struct Table2 { /// Field representing column `id` @@ -16,7 +15,7 @@ pub struct Table2 { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index f323cb68..ae7f1881 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -2,13 +2,12 @@ use crate::diesel::*; use crate::schema::*; -use serde::{Deserialize, Serialize}; use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `fang_tasks` -#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] #[diesel(table_name=fang_tasks, primary_key(id))] pub struct FangTasks { /// Field representing column `id` @@ -34,7 +33,7 @@ pub struct FangTasks { } /// Create Struct for a row in table `fang_tasks` for [`FangTasks`] -#[derive(Debug, Clone, Serialize, Deserialize, Insertable)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)] #[diesel(table_name=fang_tasks)] pub struct CreateFangTasks { /// Field representing column `id` @@ -60,7 +59,7 @@ pub struct CreateFangTasks { } /// Update Struct for a row in table `fang_tasks` for [`FangTasks`] -#[derive(Debug, Clone, Serialize, Deserialize, AsChangeset, PartialEq, Default)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)] #[diesel(table_name=fang_tasks)] pub struct UpdateFangTasks { /// Field representing column `metadata` @@ -84,7 +83,7 @@ pub struct UpdateFangTasks { } /// Result of a `.paginate` function -#[derive(Debug, Serialize)] +#[derive(Debug, serde::Serialize)] pub struct PaginationResult { /// Resulting items that are from the current page pub items: Vec, From 39da27e6b939f597e760af85080df2849a913940 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 2 Nov 2023 15:51:15 +0100 Subject: [PATCH 2/5] fix(code): change "type ConnectionType" to be public which was broken for "once-connection-type" re https://github.com/Wulf/dsync/pull/104/commits/cc0ecf2c22ef13190801f2207ddd265d1a0be86b --- src/code.rs | 2 +- test/autogenerated_all/models/todos/generated.rs | 2 +- test/autogenerated_attributes/models/todos/generated.rs | 2 +- test/autogenerated_primary_keys/models/todos/generated.rs | 2 +- test/cleanup_generated_content/models/todos/generated.rs | 2 +- test/create_update_str_cow/models/todos/generated.rs | 2 +- test/create_update_str_str/models/todos/generated.rs | 2 +- test/custom_model_and_schema_path/models/tableA/generated.rs | 2 +- test/custom_model_and_schema_path/models/tableB/generated.rs | 2 +- test/custom_model_path/models/tableA/generated.rs | 2 +- test/custom_model_path/models/tableB/generated.rs | 2 +- test/manual_primary_keys/models/todos/generated.rs | 2 +- test/multiple_primary_keys/models/users/generated.rs | 2 +- test/no_default_features/models/todos/generated.rs | 2 +- test/once_common_structs/models/table1/generated.rs | 2 +- test/once_common_structs/models/table2/generated.rs | 2 +- test/once_common_structs_once_connection_type/models/common.rs | 2 +- .../models/common.rs | 2 +- test/once_connection_type/models/common.rs | 2 +- test/readonly/models/normal/generated.rs | 2 +- test/readonly/models/prefixTable/generated.rs | 2 +- test/readonly/models/prefixTableSuffix/generated.rs | 2 +- test/readonly/models/tableSuffix/generated.rs | 2 +- test/simple_table/models/todos/generated.rs | 2 +- test/simple_table_async/models/todos/generated.rs | 2 +- test/simple_table_custom_schema_path/models/todos/generated.rs | 2 +- test/simple_table_no_serde/models/todos/generated.rs | 2 +- test/single_model_file/models/table1.rs | 2 +- test/single_model_file/models/table2.rs | 2 +- test/use_statements/models/fang_tasks/generated.rs | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/code.rs b/src/code.rs index 400165f4..5a510868 100644 --- a/src/code.rs +++ b/src/code.rs @@ -599,7 +599,7 @@ pub fn generate_common_structs(table_options: &TableOptions<'_>) -> String { /// Generate connection-type type pub fn generate_connection_type(config: &GenerationConfig) -> String { format!( - "type ConnectionType = {connection_type};", + "pub type ConnectionType = {connection_type};", connection_type = config.connection_type, ) } diff --git a/test/autogenerated_all/models/todos/generated.rs b/test/autogenerated_all/models/todos/generated.rs index a91374f3..ddf432f3 100644 --- a/test/autogenerated_all/models/todos/generated.rs +++ b/test/autogenerated_all/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/autogenerated_attributes/models/todos/generated.rs b/test/autogenerated_attributes/models/todos/generated.rs index 21a2097f..7707db68 100644 --- a/test/autogenerated_attributes/models/todos/generated.rs +++ b/test/autogenerated_attributes/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/autogenerated_primary_keys/models/todos/generated.rs b/test/autogenerated_primary_keys/models/todos/generated.rs index 53a77429..afb791e3 100644 --- a/test/autogenerated_primary_keys/models/todos/generated.rs +++ b/test/autogenerated_primary_keys/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/cleanup_generated_content/models/todos/generated.rs b/test/cleanup_generated_content/models/todos/generated.rs index 78f6f816..b6c985ed 100644 --- a/test/cleanup_generated_content/models/todos/generated.rs +++ b/test/cleanup_generated_content/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/create_update_str_cow/models/todos/generated.rs b/test/create_update_str_cow/models/todos/generated.rs index 37144f52..b8ec3511 100644 --- a/test/create_update_str_cow/models/todos/generated.rs +++ b/test/create_update_str_cow/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/create_update_str_str/models/todos/generated.rs b/test/create_update_str_str/models/todos/generated.rs index 3528fdaf..7853e6e2 100644 --- a/test/create_update_str_str/models/todos/generated.rs +++ b/test/create_update_str_str/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/custom_model_and_schema_path/models/tableA/generated.rs b/test/custom_model_and_schema_path/models/tableA/generated.rs index a042daa5..49fe31fd 100644 --- a/test/custom_model_and_schema_path/models/tableA/generated.rs +++ b/test/custom_model_and_schema_path/models/tableA/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::data::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/custom_model_and_schema_path/models/tableB/generated.rs b/test/custom_model_and_schema_path/models/tableB/generated.rs index a08f277f..84c71ab0 100644 --- a/test/custom_model_and_schema_path/models/tableB/generated.rs +++ b/test/custom_model_and_schema_path/models/tableB/generated.rs @@ -5,7 +5,7 @@ use crate::data::models::table_a::TableA; use crate::data::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/tableA/generated.rs index 21bac314..d65ad5a6 100644 --- a/test/custom_model_path/models/tableA/generated.rs +++ b/test/custom_model_path/models/tableA/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/tableB/generated.rs index 232daf2b..cbc94007 100644 --- a/test/custom_model_path/models/tableB/generated.rs +++ b/test/custom_model_path/models/tableB/generated.rs @@ -5,7 +5,7 @@ use crate::data::models::table_a::TableA; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] diff --git a/test/manual_primary_keys/models/todos/generated.rs b/test/manual_primary_keys/models/todos/generated.rs index 756dee7d..1c6636b6 100644 --- a/test/manual_primary_keys/models/todos/generated.rs +++ b/test/manual_primary_keys/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/multiple_primary_keys/models/users/generated.rs b/test/multiple_primary_keys/models/users/generated.rs index 257e9f21..43003462 100644 --- a/test/multiple_primary_keys/models/users/generated.rs +++ b/test/multiple_primary_keys/models/users/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `users` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/no_default_features/models/todos/generated.rs b/test/no_default_features/models/todos/generated.rs index dea03000..7919da1e 100644 --- a/test/no_default_features/models/todos/generated.rs +++ b/test/no_default_features/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable)] diff --git a/test/once_common_structs/models/table1/generated.rs b/test/once_common_structs/models/table1/generated.rs index c83e70a5..c22fd3ef 100644 --- a/test/once_common_structs/models/table1/generated.rs +++ b/test/once_common_structs/models/table1/generated.rs @@ -5,7 +5,7 @@ use crate::schema::*; use diesel::QueryResult; use crate::models::common::*; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/once_common_structs/models/table2/generated.rs b/test/once_common_structs/models/table2/generated.rs index 980dae85..cf297a23 100644 --- a/test/once_common_structs/models/table2/generated.rs +++ b/test/once_common_structs/models/table2/generated.rs @@ -5,7 +5,7 @@ use crate::schema::*; use diesel::QueryResult; use crate::models::common::*; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/once_common_structs_once_connection_type/models/common.rs b/test/once_common_structs_once_connection_type/models/common.rs index 781b2c5e..788b7e11 100644 --- a/test/once_common_structs_once_connection_type/models/common.rs +++ b/test/once_common_structs_once_connection_type/models/common.rs @@ -14,4 +14,4 @@ pub struct PaginationResult { pub num_pages: i64, } -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/once_common_structs_once_connection_type_single_file/models/common.rs b/test/once_common_structs_once_connection_type_single_file/models/common.rs index 781b2c5e..788b7e11 100644 --- a/test/once_common_structs_once_connection_type_single_file/models/common.rs +++ b/test/once_common_structs_once_connection_type_single_file/models/common.rs @@ -14,4 +14,4 @@ pub struct PaginationResult { pub num_pages: i64, } -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/once_connection_type/models/common.rs b/test/once_connection_type/models/common.rs index 03ffc355..eecad716 100644 --- a/test/once_connection_type/models/common.rs +++ b/test/once_connection_type/models/common.rs @@ -1,3 +1,3 @@ /* @generated and managed by dsync */ -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/readonly/models/normal/generated.rs b/test/readonly/models/normal/generated.rs index b253ece0..61d3ebeb 100644 --- a/test/readonly/models/normal/generated.rs +++ b/test/readonly/models/normal/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `normal` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/prefixTable/generated.rs b/test/readonly/models/prefixTable/generated.rs index 85950002..f5a15e94 100644 --- a/test/readonly/models/prefixTable/generated.rs +++ b/test/readonly/models/prefixTable/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTable` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/prefixTableSuffix/generated.rs b/test/readonly/models/prefixTableSuffix/generated.rs index ed8bc722..bff92fce 100644 --- a/test/readonly/models/prefixTableSuffix/generated.rs +++ b/test/readonly/models/prefixTableSuffix/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTableSuffix` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/tableSuffix/generated.rs b/test/readonly/models/tableSuffix/generated.rs index 20212f0f..5e31c190 100644 --- a/test/readonly/models/tableSuffix/generated.rs +++ b/test/readonly/models/tableSuffix/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableSuffix` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index a51b1d99..8ab9d7de 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table_async/models/todos/generated.rs b/test/simple_table_async/models/todos/generated.rs index aaa51474..f9a59684 100644 --- a/test/simple_table_async/models/todos/generated.rs +++ b/test/simple_table_async/models/todos/generated.rs @@ -5,7 +5,7 @@ use diesel_async::RunQueryDsl; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel_async::pooled_connection::deadpool::Object; +pub type ConnectionType = diesel_async::pooled_connection::deadpool::Object; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table_custom_schema_path/models/todos/generated.rs b/test/simple_table_custom_schema_path/models/todos/generated.rs index 52a37014..0f4d96ff 100644 --- a/test/simple_table_custom_schema_path/models/todos/generated.rs +++ b/test/simple_table_custom_schema_path/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::data::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table_no_serde/models/todos/generated.rs b/test/simple_table_no_serde/models/todos/generated.rs index efbbc6f2..927a38b8 100644 --- a/test/simple_table_no_serde/models/todos/generated.rs +++ b/test/simple_table_no_serde/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, Queryable, Selectable, QueryableByName)] diff --git a/test/single_model_file/models/table1.rs b/test/single_model_file/models/table1.rs index b4a8f174..96b72f59 100644 --- a/test/single_model_file/models/table1.rs +++ b/test/single_model_file/models/table1.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/single_model_file/models/table2.rs b/test/single_model_file/models/table2.rs index f52ef188..192d77b0 100644 --- a/test/single_model_file/models/table2.rs +++ b/test/single_model_file/models/table2.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index ae7f1881..4605d256 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `fang_tasks` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] From a33d1b68cbe522a7ae63340c5dd7709b0401ec2a Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 2 Nov 2023 17:55:23 +0100 Subject: [PATCH 3/5] test: fix actual PgConnection paths diesel does not have "diesel::PgConnection", only in "::prelude" or "::pg" --- README.md | 2 +- src/bin/main.rs | 2 +- test/autogenerated_all/models/todos/generated.rs | 2 +- test/autogenerated_all/test.sh | 2 +- test/autogenerated_attributes/models/todos/generated.rs | 2 +- test/autogenerated_attributes/test.sh | 2 +- test/autogenerated_primary_keys/models/todos/generated.rs | 2 +- test/autogenerated_primary_keys/test.sh | 2 +- test/cleanup_generated_content/models/todos/generated.rs | 2 +- test/cleanup_generated_content/test.sh | 4 ++-- test/create_update_str_cow/models/todos/generated.rs | 2 +- test/create_update_str_cow/test.sh | 2 +- test/create_update_str_str/models/todos/generated.rs | 2 +- test/create_update_str_str/test.sh | 2 +- test/custom_model_and_schema_path/models/tableA/generated.rs | 2 +- test/custom_model_and_schema_path/models/tableB/generated.rs | 2 +- test/custom_model_and_schema_path/test.sh | 2 +- test/custom_model_path/models/tableA/generated.rs | 2 +- test/custom_model_path/models/tableB/generated.rs | 2 +- test/custom_model_path/test.sh | 2 +- test/manual_primary_keys/models/todos/generated.rs | 2 +- test/manual_primary_keys/test.sh | 2 +- test/multiple_primary_keys/models/users/generated.rs | 2 +- test/multiple_primary_keys/test.sh | 2 +- test/once_common_structs/models/table1/generated.rs | 2 +- test/once_common_structs/models/table2/generated.rs | 2 +- test/once_common_structs/test.sh | 2 +- .../once_common_structs_once_connection_type/models/common.rs | 2 +- test/once_common_structs_once_connection_type/test.sh | 2 +- .../models/common.rs | 2 +- .../test.sh | 2 +- test/once_connection_type/models/common.rs | 2 +- test/once_connection_type/test.sh | 2 +- test/readonly/models/normal/generated.rs | 2 +- test/readonly/models/prefixTable/generated.rs | 2 +- test/readonly/models/prefixTableSuffix/generated.rs | 2 +- test/readonly/models/tableSuffix/generated.rs | 2 +- test/readonly/test.sh | 2 +- test/simple_table/models/todos/generated.rs | 2 +- test/simple_table/test.sh | 2 +- .../simple_table_custom_schema_path/models/todos/generated.rs | 2 +- test/simple_table_custom_schema_path/test.sh | 2 +- test/simple_table_no_crud/test.sh | 2 +- test/simple_table_no_serde/models/todos/generated.rs | 2 +- test/simple_table_no_serde/test.sh | 2 +- test/single_model_file/models/table1.rs | 2 +- test/single_model_file/models/table2.rs | 2 +- test/single_model_file/test.sh | 2 +- test/use_statements/models/fang_tasks/generated.rs | 2 +- test/use_statements/test.sh | 2 +- 50 files changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 4bf2f4b1..43c4a28a 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ cargo install dsync * `-i`: input argument: path to schema file * `-o`: output argument: path to directory where generated code should be written -* `-c`: connection type (for example: `diesel::r2d2::PooledConnection>`) +* `-c`: connection type (for example: `diesel::r2d2::PooledConnection>`) * `-g`: (optional, repeatable) list of columns that are automatically generated by create/update triggers (for example, `created_at`, `updated_at`) * `--tsync`: (optional) adds `#[tsync]` attribute to generated structs (see ) * `--model-path`: (optional) set a custom model import path, default `crate::models::` diff --git a/src/bin/main.rs b/src/bin/main.rs index 2ea96c25..2fcba8cb 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -63,7 +63,7 @@ pub struct MainOptions { #[arg(short = 'g', long = "autogenerated-columns")] pub autogenerated_columns: Option>, - /// rust type which describes a connection, for example: "diesel::r2d2::PooledConnection>" + /// rust type which describes a connection, for example: "diesel::r2d2::PooledConnection>" #[arg(short = 'c', long = "connection-type")] pub connection_type: String, diff --git a/test/autogenerated_all/models/todos/generated.rs b/test/autogenerated_all/models/todos/generated.rs index ddf432f3..6655ecc1 100644 --- a/test/autogenerated_all/models/todos/generated.rs +++ b/test/autogenerated_all/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/autogenerated_all/test.sh b/test/autogenerated_all/test.sh index a1a75e04..4602f622 100755 --- a/test/autogenerated_all/test.sh +++ b/test/autogenerated_all/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -g id -g created_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/autogenerated_attributes/models/todos/generated.rs b/test/autogenerated_attributes/models/todos/generated.rs index 7707db68..51346d09 100644 --- a/test/autogenerated_attributes/models/todos/generated.rs +++ b/test/autogenerated_attributes/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/autogenerated_attributes/test.sh b/test/autogenerated_attributes/test.sh index dc42cea4..af773253 100755 --- a/test/autogenerated_attributes/test.sh +++ b/test/autogenerated_attributes/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g created_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -g created_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/autogenerated_primary_keys/models/todos/generated.rs b/test/autogenerated_primary_keys/models/todos/generated.rs index afb791e3..fa92bf9b 100644 --- a/test/autogenerated_primary_keys/models/todos/generated.rs +++ b/test/autogenerated_primary_keys/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/autogenerated_primary_keys/test.sh b/test/autogenerated_primary_keys/test.sh index 3e1a5730..f9be906a 100755 --- a/test/autogenerated_primary_keys/test.sh +++ b/test/autogenerated_primary_keys/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -c "diesel::r2d2::PooledConnection>" +cargo run -- -i schema.rs -o models -g id -c "diesel::r2d2::PooledConnection>" diff --git a/test/cleanup_generated_content/models/todos/generated.rs b/test/cleanup_generated_content/models/todos/generated.rs index b6c985ed..44fae0e0 100644 --- a/test/cleanup_generated_content/models/todos/generated.rs +++ b/test/cleanup_generated_content/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/cleanup_generated_content/test.sh b/test/cleanup_generated_content/test.sh index b46239f9..a8099e7d 100755 --- a/test/cleanup_generated_content/test.sh +++ b/test/cleanup_generated_content/test.sh @@ -4,5 +4,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema1.rs -o models -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" -cargo run -- -i schema2.rs -o models -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema1.rs -o models -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" +cargo run -- -i schema2.rs -o models -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/create_update_str_cow/models/todos/generated.rs b/test/create_update_str_cow/models/todos/generated.rs index b8ec3511..75562fcb 100644 --- a/test/create_update_str_cow/models/todos/generated.rs +++ b/test/create_update_str_cow/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/create_update_str_cow/test.sh b/test/create_update_str_cow/test.sh index d78c05b7..73ab95ec 100755 --- a/test/create_update_str_cow/test.sh +++ b/test/create_update_str_cow/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --create-str=cow --update-str=cow +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --create-str=cow --update-str=cow diff --git a/test/create_update_str_str/models/todos/generated.rs b/test/create_update_str_str/models/todos/generated.rs index 7853e6e2..d7d06248 100644 --- a/test/create_update_str_str/models/todos/generated.rs +++ b/test/create_update_str_str/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/create_update_str_str/test.sh b/test/create_update_str_str/test.sh index 7a2223e6..e10fe55e 100755 --- a/test/create_update_str_str/test.sh +++ b/test/create_update_str_str/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --create-str=str --update-str=str +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --create-str=str --update-str=str diff --git a/test/custom_model_and_schema_path/models/tableA/generated.rs b/test/custom_model_and_schema_path/models/tableA/generated.rs index 49fe31fd..d4b7a998 100644 --- a/test/custom_model_and_schema_path/models/tableA/generated.rs +++ b/test/custom_model_and_schema_path/models/tableA/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::data::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/custom_model_and_schema_path/models/tableB/generated.rs b/test/custom_model_and_schema_path/models/tableB/generated.rs index 84c71ab0..0629c5b8 100644 --- a/test/custom_model_and_schema_path/models/tableB/generated.rs +++ b/test/custom_model_and_schema_path/models/tableB/generated.rs @@ -5,7 +5,7 @@ use crate::data::models::table_a::TableA; use crate::data::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] diff --git a/test/custom_model_and_schema_path/test.sh b/test/custom_model_and_schema_path/test.sh index be6266be..a3ccc5e8 100755 --- a/test/custom_model_and_schema_path/test.sh +++ b/test/custom_model_and_schema_path/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i data/schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --schema-path "crate::data::schema::" --model-path "crate::data::models::" +cargo run -- -i data/schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --schema-path "crate::data::schema::" --model-path "crate::data::models::" diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/tableA/generated.rs index d65ad5a6..e0dce556 100644 --- a/test/custom_model_path/models/tableA/generated.rs +++ b/test/custom_model_path/models/tableA/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableA` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/tableB/generated.rs index cbc94007..fcc0e7a5 100644 --- a/test/custom_model_path/models/tableB/generated.rs +++ b/test/custom_model_path/models/tableB/generated.rs @@ -5,7 +5,7 @@ use crate::data::models::table_a::TableA; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableB` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)] diff --git a/test/custom_model_path/test.sh b/test/custom_model_path/test.sh index a32e2ec6..762ee789 100755 --- a/test/custom_model_path/test.sh +++ b/test/custom_model_path/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --model-path "crate::data::models::" +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --model-path "crate::data::models::" diff --git a/test/manual_primary_keys/models/todos/generated.rs b/test/manual_primary_keys/models/todos/generated.rs index 1c6636b6..a74fb2a7 100644 --- a/test/manual_primary_keys/models/todos/generated.rs +++ b/test/manual_primary_keys/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/manual_primary_keys/test.sh b/test/manual_primary_keys/test.sh index f85a3968..d49cdd23 100755 --- a/test/manual_primary_keys/test.sh +++ b/test/manual_primary_keys/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/multiple_primary_keys/models/users/generated.rs b/test/multiple_primary_keys/models/users/generated.rs index 43003462..5b8d0151 100644 --- a/test/multiple_primary_keys/models/users/generated.rs +++ b/test/multiple_primary_keys/models/users/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `users` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/multiple_primary_keys/test.sh b/test/multiple_primary_keys/test.sh index f85a3968..d49cdd23 100755 --- a/test/multiple_primary_keys/test.sh +++ b/test/multiple_primary_keys/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/once_common_structs/models/table1/generated.rs b/test/once_common_structs/models/table1/generated.rs index c22fd3ef..5087f0db 100644 --- a/test/once_common_structs/models/table1/generated.rs +++ b/test/once_common_structs/models/table1/generated.rs @@ -5,7 +5,7 @@ use crate::schema::*; use diesel::QueryResult; use crate::models::common::*; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/once_common_structs/models/table2/generated.rs b/test/once_common_structs/models/table2/generated.rs index cf297a23..4a1744df 100644 --- a/test/once_common_structs/models/table2/generated.rs +++ b/test/once_common_structs/models/table2/generated.rs @@ -5,7 +5,7 @@ use crate::schema::*; use diesel::QueryResult; use crate::models::common::*; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/once_common_structs/test.sh b/test/once_common_structs/test.sh index 6066b36f..c98e9917 100755 --- a/test/once_common_structs/test.sh +++ b/test/once_common_structs/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs diff --git a/test/once_common_structs_once_connection_type/models/common.rs b/test/once_common_structs_once_connection_type/models/common.rs index 788b7e11..e87ef650 100644 --- a/test/once_common_structs_once_connection_type/models/common.rs +++ b/test/once_common_structs_once_connection_type/models/common.rs @@ -14,4 +14,4 @@ pub struct PaginationResult { pub num_pages: i64, } -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/once_common_structs_once_connection_type/test.sh b/test/once_common_structs_once_connection_type/test.sh index 5f071b8e..d18bbc68 100755 --- a/test/once_common_structs_once_connection_type/test.sh +++ b/test/once_common_structs_once_connection_type/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs --once-connection-type +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs --once-connection-type diff --git a/test/once_common_structs_once_connection_type_single_file/models/common.rs b/test/once_common_structs_once_connection_type_single_file/models/common.rs index 788b7e11..e87ef650 100644 --- a/test/once_common_structs_once_connection_type_single_file/models/common.rs +++ b/test/once_common_structs_once_connection_type_single_file/models/common.rs @@ -14,4 +14,4 @@ pub struct PaginationResult { pub num_pages: i64, } -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/once_common_structs_once_connection_type_single_file/test.sh b/test/once_common_structs_once_connection_type_single_file/test.sh index 56361b1b..95a120b9 100755 --- a/test/once_common_structs_once_connection_type_single_file/test.sh +++ b/test/once_common_structs_once_connection_type_single_file/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs --once-connection-type --single-model-file +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-common-structs --once-connection-type --single-model-file diff --git a/test/once_connection_type/models/common.rs b/test/once_connection_type/models/common.rs index eecad716..54c7d42c 100644 --- a/test/once_connection_type/models/common.rs +++ b/test/once_connection_type/models/common.rs @@ -1,3 +1,3 @@ /* @generated and managed by dsync */ -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; diff --git a/test/once_connection_type/test.sh b/test/once_connection_type/test.sh index 7bd0ac91..44b42841 100755 --- a/test/once_connection_type/test.sh +++ b/test/once_connection_type/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-connection-type +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --once-connection-type diff --git a/test/readonly/models/normal/generated.rs b/test/readonly/models/normal/generated.rs index 61d3ebeb..c4011c66 100644 --- a/test/readonly/models/normal/generated.rs +++ b/test/readonly/models/normal/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `normal` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/prefixTable/generated.rs b/test/readonly/models/prefixTable/generated.rs index f5a15e94..61fc2836 100644 --- a/test/readonly/models/prefixTable/generated.rs +++ b/test/readonly/models/prefixTable/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTable` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/prefixTableSuffix/generated.rs b/test/readonly/models/prefixTableSuffix/generated.rs index bff92fce..c2827b97 100644 --- a/test/readonly/models/prefixTableSuffix/generated.rs +++ b/test/readonly/models/prefixTableSuffix/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `prefixTableSuffix` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/models/tableSuffix/generated.rs b/test/readonly/models/tableSuffix/generated.rs index 5e31c190..140649dc 100644 --- a/test/readonly/models/tableSuffix/generated.rs +++ b/test/readonly/models/tableSuffix/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `tableSuffix` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/readonly/test.sh b/test/readonly/test.sh index 5a6c12fe..895965f2 100755 --- a/test/readonly/test.sh +++ b/test/readonly/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --readonly-prefix prefix --readonly-suffix Suffix +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --readonly-prefix prefix --readonly-suffix Suffix diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index 8ab9d7de..385a9d02 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table/test.sh b/test/simple_table/test.sh index acf5dbde..9f7f0d51 100755 --- a/test/simple_table/test.sh +++ b/test/simple_table/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" \ No newline at end of file diff --git a/test/simple_table_custom_schema_path/models/todos/generated.rs b/test/simple_table_custom_schema_path/models/todos/generated.rs index 0f4d96ff..367de56f 100644 --- a/test/simple_table_custom_schema_path/models/todos/generated.rs +++ b/test/simple_table_custom_schema_path/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::data::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table_custom_schema_path/test.sh b/test/simple_table_custom_schema_path/test.sh index e5a2214a..2c1cd11e 100755 --- a/test/simple_table_custom_schema_path/test.sh +++ b/test/simple_table_custom_schema_path/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i data/schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --schema-path "crate::data::schema::" +cargo run -- -i data/schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --schema-path "crate::data::schema::" diff --git a/test/simple_table_no_crud/test.sh b/test/simple_table_no_crud/test.sh index cdfdf0e7..a450db07 100755 --- a/test/simple_table_no_crud/test.sh +++ b/test/simple_table_no_crud/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --no-crud +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --no-crud diff --git a/test/simple_table_no_serde/models/todos/generated.rs b/test/simple_table_no_serde/models/todos/generated.rs index 927a38b8..39bc5169 100644 --- a/test/simple_table_no_serde/models/todos/generated.rs +++ b/test/simple_table_no_serde/models/todos/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `todos` #[derive(Debug, Clone, Queryable, Selectable, QueryableByName)] diff --git a/test/simple_table_no_serde/test.sh b/test/simple_table_no_serde/test.sh index b66ccd9d..b1b94b9f 100755 --- a/test/simple_table_no_serde/test.sh +++ b/test/simple_table_no_serde/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --no-serde +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --no-serde diff --git a/test/single_model_file/models/table1.rs b/test/single_model_file/models/table1.rs index 96b72f59..ccb7f2ce 100644 --- a/test/single_model_file/models/table1.rs +++ b/test/single_model_file/models/table1.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table1` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/single_model_file/models/table2.rs b/test/single_model_file/models/table2.rs index 192d77b0..7ab3467a 100644 --- a/test/single_model_file/models/table2.rs +++ b/test/single_model_file/models/table2.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `table2` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/single_model_file/test.sh b/test/single_model_file/test.sh index 78fec084..aaf327ad 100755 --- a/test/single_model_file/test.sh +++ b/test/single_model_file/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --single-model-file +cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection>" --single-model-file diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index 4605d256..d38f3050 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -4,7 +4,7 @@ use crate::diesel::*; use crate::schema::*; use diesel::QueryResult; -pub type ConnectionType = diesel::r2d2::PooledConnection>; +pub type ConnectionType = diesel::r2d2::PooledConnection>; /// Struct representing a row in table `fang_tasks` #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)] diff --git a/test/use_statements/test.sh b/test/use_statements/test.sh index f85a3968..d49cdd23 100755 --- a/test/use_statements/test.sh +++ b/test/use_statements/test.sh @@ -4,4 +4,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd $SCRIPT_DIR -cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file +cargo run -- -i schema.rs -o models -c "diesel::r2d2::PooledConnection>" \ No newline at end of file From 58462ca6ba529cc432e882973650114b54173dc8 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 2 Nov 2023 19:13:41 +0100 Subject: [PATCH 4/5] fix: use consistent module and directory paths for tables fixes mismatch between a tables imports and the directory structure --- src/code.rs | 6 +++--- src/lib.rs | 19 ++++++++++++++----- .../models/mod.rs | 4 ++-- .../models/{tableA => table_a}/generated.rs | 0 .../models/{tableA => table_a}/mod.rs | 0 .../models/{tableB => table_b}/generated.rs | 0 .../models/{tableB => table_b}/mod.rs | 0 test/custom_model_path/models/mod.rs | 4 ++-- .../models/{tableA => table_a}/generated.rs | 0 .../models/{tableA => table_a}/mod.rs | 0 .../models/{tableB => table_b}/generated.rs | 0 .../models/{tableB => table_b}/mod.rs | 0 test/readonly/models/mod.rs | 9 ++++++--- .../generated.rs | 0 .../{prefixTable => prefix_table}/mod.rs | 0 .../generated.rs | 0 .../mod.rs | 0 .../generated.rs | 0 .../{tableSuffix => table_suffix}/mod.rs | 0 19 files changed, 27 insertions(+), 15 deletions(-) rename test/custom_model_and_schema_path/models/{tableA => table_a}/generated.rs (100%) rename test/custom_model_and_schema_path/models/{tableA => table_a}/mod.rs (100%) rename test/custom_model_and_schema_path/models/{tableB => table_b}/generated.rs (100%) rename test/custom_model_and_schema_path/models/{tableB => table_b}/mod.rs (100%) rename test/custom_model_path/models/{tableA => table_a}/generated.rs (100%) rename test/custom_model_path/models/{tableA => table_a}/mod.rs (100%) rename test/custom_model_path/models/{tableB => table_b}/generated.rs (100%) rename test/custom_model_path/models/{tableB => table_b}/mod.rs (100%) rename test/readonly/models/{prefixTable => prefix_table}/generated.rs (100%) rename test/readonly/models/{prefixTable => prefix_table}/mod.rs (100%) rename test/readonly/models/{prefixTableSuffix => prefix_table_suffix}/generated.rs (100%) rename test/readonly/models/{prefixTableSuffix => prefix_table_suffix}/mod.rs (100%) rename test/readonly/models/{tableSuffix => table_suffix}/generated.rs (100%) rename test/readonly/models/{tableSuffix => table_suffix}/mod.rs (100%) diff --git a/src/code.rs b/src/code.rs index 5a510868..47c2ab95 100644 --- a/src/code.rs +++ b/src/code.rs @@ -1,9 +1,9 @@ -use heck::{ToPascalCase, ToSnakeCase}; +use heck::ToPascalCase; use indoc::formatdoc; use std::borrow::Cow; use crate::parser::{ParsedColumnMacro, ParsedTableMacro, FILE_SIGNATURE}; -use crate::{GenerationConfig, TableOptions}; +use crate::{get_table_module_name, GenerationConfig, TableOptions}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum StructType { @@ -615,7 +615,7 @@ fn build_imports(table: &ParsedTableMacro, config: &GenerationConfig) -> String imports_vec.extend(table.foreign_keys.iter().map(|fk| { format!( "use {model_path}{foreign_table_name_model}::{singular_struct_name};", - foreign_table_name_model = fk.0.to_string().to_snake_case().to_lowercase(), + foreign_table_name_model = get_table_module_name(&fk.0.to_string()), singular_struct_name = fk.0.to_string().to_pascal_case(), model_path = config.model_path ) diff --git a/src/lib.rs b/src/lib.rs index a42e1477..bfea8665 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,7 @@ mod parser; use error::IOErrorToError; pub use error::{Error, Result}; use file::MarkedFile; +use heck::ToSnakeCase; use parser::ParsedTableMacro; pub use parser::FILE_SIGNATURE; use std::collections::HashMap; @@ -350,6 +351,14 @@ impl From<&MarkedFile> for FileChange { } } +/// Helper function for consistent table module name generation +/// this is used for the rust module path name and for the filename +/// +/// input: "tableA", output -> "table_a" +fn get_table_module_name(table_name: &str) -> String { + table_name.to_snake_case().to_lowercase() +} + /// Generate all Models for a given diesel schema file /// /// Models are saved to disk @@ -412,11 +421,12 @@ pub fn generate_files( return Err(Error::other("Cannot have a table named \"common\" while having option \"once_common_structs\" enabled")); } let table_name = table.name.to_string(); + let table_filename = get_table_module_name(&table_name); let table_config = config.table(&table_name); let table_dir = if table_config.single_model_file { output_models_dir.to_owned() } else { - output_models_dir.join(&table_name) + output_models_dir.join(&table_filename) }; if !table_dir.exists() { @@ -451,11 +461,12 @@ pub fn generate_files( file_changes.push(FileChange::from(&table_mod_rs)); } - mod_rs.ensure_mod_stmt(&table.name.to_string()); + mod_rs.ensure_mod_stmt(&table_filename); } // pass 2: delete code for removed tables for item in std::fs::read_dir(output_models_dir).attach_path_err(output_models_dir)? { + // TODO: this does not work with "single-model-file" let item = item.attach_path_err(output_models_dir)?; // check if item is a directory @@ -482,9 +493,7 @@ pub fn generate_files( item.path() )))?; let found = generated.iter().find(|g| { - g.name - .to_string() - .eq_ignore_ascii_case(associated_table_name) + get_table_module_name(&g.name.to_string()).eq_ignore_ascii_case(associated_table_name) }); if found.is_some() { continue; diff --git a/test/custom_model_and_schema_path/models/mod.rs b/test/custom_model_and_schema_path/models/mod.rs index 0bcf1b97..9379294b 100644 --- a/test/custom_model_and_schema_path/models/mod.rs +++ b/test/custom_model_and_schema_path/models/mod.rs @@ -1,2 +1,2 @@ -pub mod tableA; -pub mod tableB; \ No newline at end of file +pub mod table_a; +pub mod table_b; \ No newline at end of file diff --git a/test/custom_model_and_schema_path/models/tableA/generated.rs b/test/custom_model_and_schema_path/models/table_a/generated.rs similarity index 100% rename from test/custom_model_and_schema_path/models/tableA/generated.rs rename to test/custom_model_and_schema_path/models/table_a/generated.rs diff --git a/test/custom_model_and_schema_path/models/tableA/mod.rs b/test/custom_model_and_schema_path/models/table_a/mod.rs similarity index 100% rename from test/custom_model_and_schema_path/models/tableA/mod.rs rename to test/custom_model_and_schema_path/models/table_a/mod.rs diff --git a/test/custom_model_and_schema_path/models/tableB/generated.rs b/test/custom_model_and_schema_path/models/table_b/generated.rs similarity index 100% rename from test/custom_model_and_schema_path/models/tableB/generated.rs rename to test/custom_model_and_schema_path/models/table_b/generated.rs diff --git a/test/custom_model_and_schema_path/models/tableB/mod.rs b/test/custom_model_and_schema_path/models/table_b/mod.rs similarity index 100% rename from test/custom_model_and_schema_path/models/tableB/mod.rs rename to test/custom_model_and_schema_path/models/table_b/mod.rs diff --git a/test/custom_model_path/models/mod.rs b/test/custom_model_path/models/mod.rs index 0bcf1b97..9379294b 100644 --- a/test/custom_model_path/models/mod.rs +++ b/test/custom_model_path/models/mod.rs @@ -1,2 +1,2 @@ -pub mod tableA; -pub mod tableB; \ No newline at end of file +pub mod table_a; +pub mod table_b; \ No newline at end of file diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/table_a/generated.rs similarity index 100% rename from test/custom_model_path/models/tableA/generated.rs rename to test/custom_model_path/models/table_a/generated.rs diff --git a/test/custom_model_path/models/tableA/mod.rs b/test/custom_model_path/models/table_a/mod.rs similarity index 100% rename from test/custom_model_path/models/tableA/mod.rs rename to test/custom_model_path/models/table_a/mod.rs diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/table_b/generated.rs similarity index 100% rename from test/custom_model_path/models/tableB/generated.rs rename to test/custom_model_path/models/table_b/generated.rs diff --git a/test/custom_model_path/models/tableB/mod.rs b/test/custom_model_path/models/table_b/mod.rs similarity index 100% rename from test/custom_model_path/models/tableB/mod.rs rename to test/custom_model_path/models/table_b/mod.rs diff --git a/test/readonly/models/mod.rs b/test/readonly/models/mod.rs index 2593f3ec..197b4003 100644 --- a/test/readonly/models/mod.rs +++ b/test/readonly/models/mod.rs @@ -1,4 +1,7 @@ pub mod normal; -pub mod prefixTable; -pub mod tableSuffix; -pub mod prefixTableSuffix; + + + +pub mod prefix_table; +pub mod table_suffix; +pub mod prefix_table_suffix; \ No newline at end of file diff --git a/test/readonly/models/prefixTable/generated.rs b/test/readonly/models/prefix_table/generated.rs similarity index 100% rename from test/readonly/models/prefixTable/generated.rs rename to test/readonly/models/prefix_table/generated.rs diff --git a/test/readonly/models/prefixTable/mod.rs b/test/readonly/models/prefix_table/mod.rs similarity index 100% rename from test/readonly/models/prefixTable/mod.rs rename to test/readonly/models/prefix_table/mod.rs diff --git a/test/readonly/models/prefixTableSuffix/generated.rs b/test/readonly/models/prefix_table_suffix/generated.rs similarity index 100% rename from test/readonly/models/prefixTableSuffix/generated.rs rename to test/readonly/models/prefix_table_suffix/generated.rs diff --git a/test/readonly/models/prefixTableSuffix/mod.rs b/test/readonly/models/prefix_table_suffix/mod.rs similarity index 100% rename from test/readonly/models/prefixTableSuffix/mod.rs rename to test/readonly/models/prefix_table_suffix/mod.rs diff --git a/test/readonly/models/tableSuffix/generated.rs b/test/readonly/models/table_suffix/generated.rs similarity index 100% rename from test/readonly/models/tableSuffix/generated.rs rename to test/readonly/models/table_suffix/generated.rs diff --git a/test/readonly/models/tableSuffix/mod.rs b/test/readonly/models/table_suffix/mod.rs similarity index 100% rename from test/readonly/models/tableSuffix/mod.rs rename to test/readonly/models/table_suffix/mod.rs From 830655ebdc9ecc273ec7e1c6645fd5f6215d5dbc Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sun, 19 Nov 2023 13:50:00 +0100 Subject: [PATCH 5/5] style(lib): add extra examples to `connection_type` in GenerationConfig and binary help --- src/bin/main.rs | 11 +++++++++-- src/lib.rs | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index 2fcba8cb..574b4098 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -63,8 +63,15 @@ pub struct MainOptions { #[arg(short = 'g', long = "autogenerated-columns")] pub autogenerated_columns: Option>, - /// rust type which describes a connection, for example: "diesel::r2d2::PooledConnection>" - #[arg(short = 'c', long = "connection-type")] + /// rust type which describes a connection + /// + /// For example: + /// - `diesel::pg::PgConnection` + /// - `diesel::sqlite::SqliteConnection` + /// - `diesel::mysql::MysqlConnection` + /// - `diesel::r2d2::PooledConnection>` + /// - or, your custom diesel connection type (struct which implements `diesel::connection::Connection`) + #[arg(short = 'c', long = "connection-type", verbatim_doc_comment)] pub connection_type: String, /// Disable generating serde implementations diff --git a/src/lib.rs b/src/lib.rs index bfea8665..6b8bc6e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,7 +248,12 @@ pub struct GenerationConfig<'a> { pub default_table_options: TableOptions<'a>, /// Connection type to insert /// - /// Example: `diesel::SqliteConnection` + /// For example: + /// - `diesel::pg::PgConnection` + /// - `diesel::sqlite::SqliteConnection` + /// - `diesel::mysql::MysqlConnection` + /// - `diesel::r2d2::PooledConnection>` + /// - or, your custom diesel connection type (struct which implements `diesel::connection::Connection`) pub connection_type: String, /// Diesel schema import path ///