From c72ce72e6806d7b21ea9860b3bf950692b4ace76 Mon Sep 17 00:00:00 2001 From: Jacob Phillips Date: Thu, 21 Mar 2024 22:36:16 +0000 Subject: [PATCH] fix #21 --- example/src/person.rs | 2 ++ macros/src/derive/entity/field/map_helper.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/example/src/person.rs b/example/src/person.rs index c65e230..c1c8ab8 100644 --- a/example/src/person.rs +++ b/example/src/person.rs @@ -11,6 +11,7 @@ pub struct Person { age: Option, /// Favorite colors colors: Vec, + photo_url: Option, } #[derive(Relation)] @@ -46,6 +47,7 @@ mod tests { "name", Some(42), &["red".to_owned(), "blue".to_owned()], + None, ); assert_eq!(p.id(), "id"); let p = p.into_builder().name("name2").build(); diff --git a/macros/src/derive/entity/field/map_helper.rs b/macros/src/derive/entity/field/map_helper.rs index 58da3d9..48cb366 100644 --- a/macros/src/derive/entity/field/map_helper.rs +++ b/macros/src/derive/entity/field/map_helper.rs @@ -118,7 +118,7 @@ pub fn field_from_boltmap(name: &str, typ: &FieldType) -> TokenStream { } FieldType::OptionOther(_ty) => { quote!( - value.get(#name) + value.get(#name).map_err(|e| ::cypher_dto::Error::MissingField(#name.to_owned()))? ) } FieldType::Other(_ty) => {