Skip to content

Commit 18f7f14

Browse files
committed
DocumentPartial skip id field
1 parent bec629d commit 18f7f14

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

typesense_derive/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
7777
proc_macro2::TokenStream::new()
7878
};
7979

80-
let optional_fields = fields.iter().map(|f| {
80+
let optional_fields = fields.iter().filter_map(|f| {
81+
let ident = f.ident.as_ref()?;
82+
if ident == "id" {
83+
return None;
84+
}
8185
let vis = &f.vis;
82-
let ident = &f.ident;
8386
let ty = &f.ty;
84-
quote! {
87+
88+
Some(quote! {
8589
#[serde(skip_serializing_if = "Option::is_none")]
8690
#vis #ident: Option<#ty>,
87-
}
91+
})
8892
});
8993

9094
let name_partial = Ident::new(&(ident.to_string() + "Partial"), ident.span());

0 commit comments

Comments
 (0)