Remove panic
This commit is contained in:
parent
0eb6902d1b
commit
cc2f491a1e
@ -1,7 +1,7 @@
|
||||
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use quote::quote;
|
||||
use syn::{Attribute, Data, Fields, Lit, Meta, punctuated::Punctuated, token::Comma};
|
||||
use syn::{Attribute, Data, Fields, Lit, Meta, parse::Error, punctuated::Punctuated, spanned::Spanned, token::Comma};
|
||||
|
||||
use convert_case::{Case, Casing};
|
||||
|
||||
@ -103,7 +103,10 @@ impl sea_orm::prelude::EntityName for Entity {
|
||||
}
|
||||
}
|
||||
});
|
||||
let field_type = sql_type.unwrap_or_else(|| {
|
||||
|
||||
let field_type = match sql_type {
|
||||
Some(t) => t,
|
||||
None => {
|
||||
let field_type = &field.ty;
|
||||
let temp = quote! { #field_type }
|
||||
.to_string()//E.g.: "Option < String >"
|
||||
@ -130,9 +133,10 @@ impl sea_orm::prelude::EntityName for Entity {
|
||||
"NaiveDateTime" => quote! { DateTime },
|
||||
"Uuid" => quote! { Uuid },
|
||||
"Decimal" => quote! { BigInteger },
|
||||
_ => panic!("unrecognized type {}", temp),
|
||||
_ => return Err(Error::new(field.span(), format!("unrecognized type {}", temp))),
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let mut match_row = quote! { Self::#field_name => sea_orm::prelude::ColumnType::#field_type.def() };
|
||||
if nullable {
|
||||
|
Loading…
x
Reference in New Issue
Block a user