Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lukasschlueter/sea-orm into lukas…
Browse files Browse the repository at this point in the history
…schlueter-master
  • Loading branch information
onefifth committed Nov 1, 2023
2 parents 06c6327 + 7cf3195 commit f9020c5
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sea-orm-codegen/src/entity/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,23 @@ impl EntityWriter {
entity
.columns
.iter()
.fold(TokenStream::new(), |mut ts, col| {
if let sea_query::ColumnType::Enum { name, .. } = col.get_inner_col_type() {
let enum_name = format_ident!("{}", name.to_string().to_upper_camel_case());
ts.extend([quote! {
use super::sea_orm_active_enums::#enum_name;
}]);
}
ts
})
.fold(
(TokenStream::new(), Vec::new()),
|(mut ts, mut enums), col| {
if let sea_query::ColumnType::Enum { name, .. } = col.get_inner_col_type() {
if !enums.contains(&name) {
enums.push(name);
let enum_name =
format_ident!("{}", name.to_string().to_upper_camel_case());
ts.extend([quote! {
use super::sea_orm_active_enums::#enum_name;
}]);
}
}
(ts, enums)
},
)
.0
}

pub fn gen_model_struct(
Expand Down

0 comments on commit f9020c5

Please sign in to comment.