From 14258a0ab095776565215c3524bc7c62fe154ae4 Mon Sep 17 00:00:00 2001 From: Janosch Reppnow Date: Sat, 30 Mar 2024 21:48:03 +0900 Subject: [PATCH] fix: add comment explaining error handling in FromQueryResult derive --- sea-orm-macros/src/derives/from_query_result.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sea-orm-macros/src/derives/from_query_result.rs b/sea-orm-macros/src/derives/from_query_result.rs index 2507dc496..70ad20b09 100644 --- a/sea-orm-macros/src/derives/from_query_result.rs +++ b/sea-orm-macros/src/derives/from_query_result.rs @@ -16,6 +16,15 @@ struct FromQueryResultItem { pub ident: Ident, } +/// Initially, we try to obtain the value for each field and check if it is an ordinary DB error +/// (which we return immediatly), or a null error. +/// +/// ### Background +/// +/// Null errors do not necessarily mean that the deserialization as a whole fails, +/// since structs embedding the current one might have wrapped the current one in an `Option`. +/// In this case, we do not want to swallow other errors, which are very likely to actually be +/// programming errors that should be noticed (and fixed). struct TryFromQueryResultCheck<'a>(&'a FromQueryResultItem); impl<'a> ToTokens for TryFromQueryResultCheck<'a> {