Skip to content

Commit

Permalink
Address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed May 10, 2021
1 parent d210f45 commit ea02c36
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions diesel_derives/src/queryable_by_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,13 @@ pub fn derive(item: syn::DeriveInput) -> Result<proc_macro2::TokenStream, Diagno
} else {
let field_ty = &f.ty;
let deserialize_ty = f.ty_for_deserialize()?;
if model.has_table_name_attribute() {
let name = f.column_name_ident();
Ok(quote!(
{
let field = diesel::row::NamedRow::get(row, stringify!(#name))?;
<#deserialize_ty as Into<#field_ty>>::into(field)
}
))
} else {
let name = f.column_name_str();
Ok(quote!(
{
let field = diesel::row::NamedRow::get(row, #name)?;
<#deserialize_ty as Into<#field_ty>>::into(field)
}
))
}
let name = f.column_name_str();
Ok(quote!(
{
let field = diesel::row::NamedRow::get(row, #name)?;
<#deserialize_ty as Into<#field_ty>>::into(field)
}
))
}
})
.collect::<Result<Vec<_>, Diagnostic>>()?;
Expand Down

0 comments on commit ea02c36

Please sign in to comment.