From 2633bb83f5d4bad7a0ff7fbc7e8fd86ff7739a1b Mon Sep 17 00:00:00 2001 From: hasezoey Date: Mon, 9 Oct 2023 17:48:39 +0200 Subject: [PATCH] fix(code): remove extra new-line between struct and paginationresult also add a new-line inbetween the file-signature and code in "common.rs" to be consistent with other files --- src/code.rs | 6 +++--- src/lib.rs | 2 +- test/autogenerated_all/models/todos/generated.rs | 1 - test/autogenerated_attributes/models/todos/generated.rs | 1 - test/autogenerated_primary_keys/models/todos/generated.rs | 1 - test/cleanup_generated_content/models/todos/generated.rs | 1 - test/create_update_str_cow/models/todos/generated.rs | 1 - test/create_update_str_str/models/todos/generated.rs | 1 - .../models/tableA/generated.rs | 1 - .../models/tableB/generated.rs | 1 - test/custom_model_path/models/tableA/generated.rs | 1 - test/custom_model_path/models/tableB/generated.rs | 1 - test/manual_primary_keys/models/todos/generated.rs | 1 - test/multiple_primary_keys/models/users/generated.rs | 1 - test/once_connection_type/models/common.rs | 1 + test/once_connection_type/models/table1/generated.rs | 1 - test/once_connection_type/models/table2/generated.rs | 1 - test/readonly/models/normal/generated.rs | 8 ++------ test/readonly/models/prefixTable/generated.rs | 8 ++------ test/readonly/models/prefixTableSuffix/generated.rs | 8 ++------ test/readonly/models/tableSuffix/generated.rs | 8 ++------ test/simple_table/models/todos/generated.rs | 1 - test/simple_table_async/models/todos/generated.rs | 1 - .../models/todos/generated.rs | 1 - test/simple_table_no_serde/models/todos/generated.rs | 1 - test/single_model_file/models/table1.rs | 1 - test/single_model_file/models/table2.rs | 1 - test/use_statements/models/fang_tasks/generated.rs | 1 - 28 files changed, 13 insertions(+), 49 deletions(-) diff --git a/src/code.rs b/src/code.rs index 5e671cd8..4c2e2f68 100644 --- a/src/code.rs +++ b/src/code.rs @@ -518,15 +518,15 @@ fn build_table_fns( pub fn generate_common_structs(table_options: &TableOptions<'_>) -> String { #[cfg(feature = "tsync")] let tsync = match table_options.get_tsync() { - true => "#[tsync::tsync]", + true => "#[tsync::tsync]\n", false => "", }; #[cfg(not(feature = "tsync"))] let tsync = ""; formatdoc!( - r##"{tsync} - #[derive({debug_derive}, {serde_derive})] + r##" + {tsync}#[derive({debug_derive}, {serde_derive})] pub struct PaginationResult {{ pub items: Vec, pub total_items: i64, diff --git a/src/lib.rs b/src/lib.rs index 073bd9f2..c1e2b41c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -383,7 +383,7 @@ pub fn generate_files( let mut common_file = MarkedFile::new(output_models_dir.join("common.rs"))?; common_file.ensure_file_signature()?; common_file.change_file_contents({ - let mut tmp = String::from(FILE_SIGNATURE); + let mut tmp = format!("{FILE_SIGNATURE}\n"); if config.once_common_structs { tmp.push_str(&code::generate_common_structs( &config.default_table_options, diff --git a/test/autogenerated_all/models/todos/generated.rs b/test/autogenerated_all/models/todos/generated.rs index 82e712c0..12e0530a 100644 --- a/test/autogenerated_all/models/todos/generated.rs +++ b/test/autogenerated_all/models/todos/generated.rs @@ -20,7 +20,6 @@ pub struct UpdateTodos { pub created_at: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/autogenerated_attributes/models/todos/generated.rs b/test/autogenerated_attributes/models/todos/generated.rs index aa86dfa2..7af9c77e 100644 --- a/test/autogenerated_attributes/models/todos/generated.rs +++ b/test/autogenerated_attributes/models/todos/generated.rs @@ -26,7 +26,6 @@ pub struct UpdateTodos { pub created_at: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/autogenerated_primary_keys/models/todos/generated.rs b/test/autogenerated_primary_keys/models/todos/generated.rs index 95602ffe..82d2f095 100644 --- a/test/autogenerated_primary_keys/models/todos/generated.rs +++ b/test/autogenerated_primary_keys/models/todos/generated.rs @@ -26,7 +26,6 @@ pub struct UpdateTodos { pub text: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/cleanup_generated_content/models/todos/generated.rs b/test/cleanup_generated_content/models/todos/generated.rs index 45b36c19..e274198b 100644 --- a/test/cleanup_generated_content/models/todos/generated.rs +++ b/test/cleanup_generated_content/models/todos/generated.rs @@ -34,7 +34,6 @@ pub struct UpdateTodos { pub updated_at: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { 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 df6d5b77..0e6fd50c 100644 --- a/test/create_update_str_cow/models/todos/generated.rs +++ b/test/create_update_str_cow/models/todos/generated.rs @@ -33,7 +33,6 @@ pub struct UpdateTodos<'a> { pub varchar_nullable: Option>>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { 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 35ff73b1..ddf9a95b 100644 --- a/test/create_update_str_str/models/todos/generated.rs +++ b/test/create_update_str_str/models/todos/generated.rs @@ -33,7 +33,6 @@ pub struct UpdateTodos<'a> { pub varchar_nullable: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { 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 40f3b8c9..d45f94cd 100644 --- a/test/custom_model_and_schema_path/models/tableA/generated.rs +++ b/test/custom_model_and_schema_path/models/tableA/generated.rs @@ -19,7 +19,6 @@ pub struct CreateTableA { pub _id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { 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 857fed74..f0e88858 100644 --- a/test/custom_model_and_schema_path/models/tableB/generated.rs +++ b/test/custom_model_and_schema_path/models/tableB/generated.rs @@ -28,7 +28,6 @@ pub struct UpdateTableB { pub link: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/tableA/generated.rs index 04075c20..6cbc2247 100644 --- a/test/custom_model_path/models/tableA/generated.rs +++ b/test/custom_model_path/models/tableA/generated.rs @@ -19,7 +19,6 @@ pub struct CreateTableA { pub _id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/tableB/generated.rs index 429b1900..8e177ff9 100644 --- a/test/custom_model_path/models/tableB/generated.rs +++ b/test/custom_model_path/models/tableB/generated.rs @@ -28,7 +28,6 @@ pub struct UpdateTableB { pub link: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/manual_primary_keys/models/todos/generated.rs b/test/manual_primary_keys/models/todos/generated.rs index cbbe73b4..e0bb1e1e 100644 --- a/test/manual_primary_keys/models/todos/generated.rs +++ b/test/manual_primary_keys/models/todos/generated.rs @@ -19,7 +19,6 @@ pub struct CreateTodos { pub id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/multiple_primary_keys/models/users/generated.rs b/test/multiple_primary_keys/models/users/generated.rs index bd2974e6..5379a456 100644 --- a/test/multiple_primary_keys/models/users/generated.rs +++ b/test/multiple_primary_keys/models/users/generated.rs @@ -29,7 +29,6 @@ pub struct UpdateUsers { pub secret: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/once_connection_type/models/common.rs b/test/once_connection_type/models/common.rs index 38564fe1..1fdc88f6 100644 --- a/test/once_connection_type/models/common.rs +++ b/test/once_connection_type/models/common.rs @@ -1,2 +1,3 @@ /* @generated and managed by dsync */ + type ConnectionType = diesel::r2d2::PooledConnection>; \ No newline at end of file diff --git a/test/once_connection_type/models/table1/generated.rs b/test/once_connection_type/models/table1/generated.rs index 257b83d7..359be4f7 100644 --- a/test/once_connection_type/models/table1/generated.rs +++ b/test/once_connection_type/models/table1/generated.rs @@ -12,7 +12,6 @@ pub struct Table1 { pub id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/once_connection_type/models/table2/generated.rs b/test/once_connection_type/models/table2/generated.rs index dabbd67d..4d8cfdf3 100644 --- a/test/once_connection_type/models/table2/generated.rs +++ b/test/once_connection_type/models/table2/generated.rs @@ -12,7 +12,6 @@ pub struct Table2 { pub id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/readonly/models/normal/generated.rs b/test/readonly/models/normal/generated.rs index 00fa8fd5..92fc6a53 100644 --- a/test/readonly/models/normal/generated.rs +++ b/test/readonly/models/normal/generated.rs @@ -2,9 +2,8 @@ use crate::diesel::*; use crate::schema::*; -use diesel::QueryResult; use serde::{Deserialize, Serialize}; - +use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; @@ -27,7 +26,6 @@ pub struct UpdateNormal { pub testprop: Option, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, @@ -39,7 +37,6 @@ pub struct PaginationResult { } impl Normal { - pub fn create(db: &mut ConnectionType, item: &CreateNormal) -> QueryResult { use crate::schema::normal::dsl::*; @@ -81,5 +78,4 @@ impl Normal { diesel::delete(normal.filter(id.eq(param_id))).execute(db) } - -} \ No newline at end of file +} diff --git a/test/readonly/models/prefixTable/generated.rs b/test/readonly/models/prefixTable/generated.rs index 513949ff..74ea0f74 100644 --- a/test/readonly/models/prefixTable/generated.rs +++ b/test/readonly/models/prefixTable/generated.rs @@ -2,9 +2,8 @@ use crate::diesel::*; use crate::schema::*; -use diesel::QueryResult; use serde::{Deserialize, Serialize}; - +use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; @@ -15,7 +14,6 @@ pub struct PrefixTable { pub testprop: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, @@ -27,7 +25,6 @@ pub struct PaginationResult { } impl PrefixTable { - pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::prefixTable::dsl::*; @@ -51,5 +48,4 @@ impl PrefixTable { num_pages: total_items / page_size + i64::from(total_items % page_size != 0) }) } - -} \ No newline at end of file +} diff --git a/test/readonly/models/prefixTableSuffix/generated.rs b/test/readonly/models/prefixTableSuffix/generated.rs index 2cdf82c3..7bce0a4e 100644 --- a/test/readonly/models/prefixTableSuffix/generated.rs +++ b/test/readonly/models/prefixTableSuffix/generated.rs @@ -2,9 +2,8 @@ use crate::diesel::*; use crate::schema::*; -use diesel::QueryResult; use serde::{Deserialize, Serialize}; - +use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; @@ -15,7 +14,6 @@ pub struct PrefixTableSuffix { pub testprop: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, @@ -27,7 +25,6 @@ pub struct PaginationResult { } impl PrefixTableSuffix { - pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::prefixTableSuffix::dsl::*; @@ -51,5 +48,4 @@ impl PrefixTableSuffix { num_pages: total_items / page_size + i64::from(total_items % page_size != 0) }) } - -} \ No newline at end of file +} diff --git a/test/readonly/models/tableSuffix/generated.rs b/test/readonly/models/tableSuffix/generated.rs index 37fba90e..ee4ee0fd 100644 --- a/test/readonly/models/tableSuffix/generated.rs +++ b/test/readonly/models/tableSuffix/generated.rs @@ -2,9 +2,8 @@ use crate::diesel::*; use crate::schema::*; -use diesel::QueryResult; use serde::{Deserialize, Serialize}; - +use diesel::QueryResult; type ConnectionType = diesel::r2d2::PooledConnection>; @@ -15,7 +14,6 @@ pub struct TableSuffix { pub testprop: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, @@ -27,7 +25,6 @@ pub struct PaginationResult { } impl TableSuffix { - pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::tableSuffix::dsl::*; @@ -51,5 +48,4 @@ impl TableSuffix { num_pages: total_items / page_size + i64::from(total_items % page_size != 0) }) } - -} \ No newline at end of file +} diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index 425b0564..7ad5dd2e 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -42,7 +42,6 @@ pub struct UpdateTodos { pub updated_at: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/simple_table_async/models/todos/generated.rs b/test/simple_table_async/models/todos/generated.rs index 5b12a6f2..2a2eca2d 100644 --- a/test/simple_table_async/models/todos/generated.rs +++ b/test/simple_table_async/models/todos/generated.rs @@ -37,7 +37,6 @@ pub struct UpdateTodos { pub updated_at: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { 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 d5090438..3899a332 100644 --- a/test/simple_table_custom_schema_path/models/todos/generated.rs +++ b/test/simple_table_custom_schema_path/models/todos/generated.rs @@ -36,7 +36,6 @@ pub struct UpdateTodos { pub updated_at: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/simple_table_no_serde/models/todos/generated.rs b/test/simple_table_no_serde/models/todos/generated.rs index 6557c95d..82f61f3b 100644 --- a/test/simple_table_no_serde/models/todos/generated.rs +++ b/test/simple_table_no_serde/models/todos/generated.rs @@ -35,7 +35,6 @@ pub struct UpdateTodos { pub updated_at: Option>, } - #[derive(Debug, )] pub struct PaginationResult { pub items: Vec, diff --git a/test/single_model_file/models/table1.rs b/test/single_model_file/models/table1.rs index 8374d92a..bd66bc49 100644 --- a/test/single_model_file/models/table1.rs +++ b/test/single_model_file/models/table1.rs @@ -13,7 +13,6 @@ pub struct Table1 { pub id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/single_model_file/models/table2.rs b/test/single_model_file/models/table2.rs index 7a6397d1..e6d4ac1c 100644 --- a/test/single_model_file/models/table2.rs +++ b/test/single_model_file/models/table2.rs @@ -13,7 +13,6 @@ pub struct Table2 { pub id: i32, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec, diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index 97d8946c..3114cd22 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -51,7 +51,6 @@ pub struct UpdateFangTasks { pub updated_at: Option>, } - #[derive(Debug, Serialize)] pub struct PaginationResult { pub items: Vec,