From 665b859645088cb8dcc01c75d28e3eadf533f093 Mon Sep 17 00:00:00 2001 From: Gregor Giesen Date: Sat, 21 Jan 2023 21:24:25 +0100 Subject: [PATCH] derive FromRow: added attribute skip for setting default value --- sqlx-macros-core/src/derives/attributes.rs | 4 ++++ sqlx-macros-core/src/derives/row.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/sqlx-macros-core/src/derives/attributes.rs b/sqlx-macros-core/src/derives/attributes.rs index bf3c126c..bfbc32f6 100644 --- a/sqlx-macros-core/src/derives/attributes.rs +++ b/sqlx-macros-core/src/derives/attributes.rs @@ -63,6 +63,7 @@ pub struct SqlxChildAttributes { pub default: bool, pub flatten: bool, pub try_from: Option, + pub skip: bool, } pub fn parse_container_attributes(input: &[Attribute]) -> syn::Result { @@ -155,6 +156,7 @@ pub fn parse_child_attributes(input: &[Attribute]) -> syn::Result syn::Result try_set!(try_from, val.parse()?, value), Meta::Path(path) if path.is_ident("default") => default = true, Meta::Path(path) if path.is_ident("flatten") => flatten = true, + Meta::Path(path) if path.is_ident("skip") => skip = true, u => fail!(u, "unexpected attribute"), }, u => fail!(u, "unexpected attribute"), @@ -190,6 +193,7 @@ pub fn parse_child_attributes(input: &[Attribute]) -> syn::Result { predicates.push(parse_quote!(#ty: ::sqlx::FromRow<#lifetime, R>));