Fix DeriveActiveEnum expand enum variant starts with number (#1219)
This commit is contained in:
parent
2f555e1fb5
commit
1be6673f0e
@ -246,7 +246,13 @@ impl ActiveEnum {
|
|||||||
let enum_variant_iden = format_ident!("{}Variant", ident);
|
let enum_variant_iden = format_ident!("{}Variant", ident);
|
||||||
let enum_variants: Vec<syn::Ident> = str_variants
|
let enum_variants: Vec<syn::Ident> = str_variants
|
||||||
.iter()
|
.iter()
|
||||||
.map(|v| format_ident!("{}", v.to_camel_case()))
|
.map(|v| {
|
||||||
|
if v.chars().next().map(char::is_numeric).unwrap_or(false) {
|
||||||
|
format_ident!("_{}", v)
|
||||||
|
} else {
|
||||||
|
format_ident!("{}", v.to_camel_case())
|
||||||
|
}
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
quote!(
|
quote!(
|
||||||
|
@ -26,3 +26,30 @@ pub enum Tea {
|
|||||||
#[sea_orm(string_value = "BreakfastTea")]
|
#[sea_orm(string_value = "BreakfastTea")]
|
||||||
BreakfastTea,
|
BreakfastTea,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
|
||||||
|
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "media_type")]
|
||||||
|
pub enum MediaType {
|
||||||
|
#[sea_orm(string_value = "UNKNOWN")]
|
||||||
|
Unknown,
|
||||||
|
#[sea_orm(string_value = "BITMAP")]
|
||||||
|
Bitmap,
|
||||||
|
#[sea_orm(string_value = "DRAWING")]
|
||||||
|
Drawing,
|
||||||
|
#[sea_orm(string_value = "AUDIO")]
|
||||||
|
Audio,
|
||||||
|
#[sea_orm(string_value = "VIDEO")]
|
||||||
|
Video,
|
||||||
|
#[sea_orm(string_value = "MULTIMEDIA")]
|
||||||
|
Multimedia,
|
||||||
|
#[sea_orm(string_value = "OFFICE")]
|
||||||
|
Office,
|
||||||
|
#[sea_orm(string_value = "TEXT")]
|
||||||
|
Text,
|
||||||
|
#[sea_orm(string_value = "EXECUTABLE")]
|
||||||
|
Executable,
|
||||||
|
#[sea_orm(string_value = "ARCHIVE")]
|
||||||
|
Archive,
|
||||||
|
#[sea_orm(string_value = "3D")]
|
||||||
|
_3D,
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user