From 8a68c01d51bdbc9efc5f3f764d85ddfef3a4951c Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 30 Sep 2023 20:10:01 +0200 Subject: [PATCH] fix(code): dont modify "base_type" with "Option" wrapping because that is what the "is_optional" bool is for, also it would result in "Option>" for "Update" structs --- src/code.rs | 7 +------ test/simple_table/models/todos/generated.rs | 2 +- test/use_statements/models/fang_tasks/generated.rs | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/code.rs b/src/code.rs index f74bf87c..0f5f375e 100644 --- a/src/code.rs +++ b/src/code.rs @@ -181,12 +181,7 @@ impl<'a> Struct<'a> { } else { c.ty.clone() }; - let base_type = if c.is_nullable { - format!("Option<{}>", base_type) - } else { - base_type - }; - let mut is_optional = false; + let mut is_optional = c.is_nullable; let is_pk = self .table diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index 65c94a10..4c094865 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -35,7 +35,7 @@ pub struct CreateTodo { #[diesel(table_name=todos)] pub struct UpdateTodo { pub unsigned: Option, - pub unsigned_nullable: Option>, + pub unsigned_nullable: Option, pub text: Option, pub completed: Option, pub type_: Option, diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index 0a570359..d49c9d4b 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -42,10 +42,10 @@ pub struct CreateFangTask { #[diesel(table_name=fang_tasks)] pub struct UpdateFangTask { pub metadata: Option, - pub error_message: Option>, + pub error_message: Option, pub state: Option, pub task_type: Option, - pub uniq_hash: Option>, + pub uniq_hash: Option, pub retries: Option, pub scheduled_at: Option>, pub created_at: Option>,