Skip to content

Commit

Permalink
Fix problems in SeaQL#1819
Browse files Browse the repository at this point in the history
  • Loading branch information
Cinea4678 committed Aug 22, 2023
1 parent af52e86 commit 5e565e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sea-orm-codegen/src/entity/active_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ impl ActiveEnum {
if v.chars().next().map(char::is_numeric).unwrap_or(false) {
format_ident!("_{}", v)
} else {
format_ident!("{}", v.to_upper_camel_case())
let variant_name = v.to_upper_camel_case();
if variant_name.is_empty() {
println!("Warning: item '{}' in the enumeration '{}' cannot be converted into a valid Rust enum member name. It will be converted to its corresponding UTF-8 encoding. You can modify it later as needed.", v, enum_name);
let mut utf_string = String::new();
for c in v.chars() {
utf_string.push('U');
utf_string.push_str(&format!("{:04X}", c as u32));
}
format_ident!("{}", utf_string)
} else {
format_ident!("{}", variant_name)
}
}
});

Expand Down

0 comments on commit 5e565e0

Please sign in to comment.