sea-orm-codegen: PostgreSQL enum arrays (#1678)
* sea-orm-codegen: PostgreSQL enum arrays * Refactoring --------- Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
parent
217894ddad
commit
73a57836fa
@ -249,6 +249,13 @@ impl Column {
|
|||||||
quote! {}
|
quote! {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_inner_col_type(&self) -> &ColumnType {
|
||||||
|
match &self.col_type {
|
||||||
|
ColumnType::Array(inner_col_type) => inner_col_type.as_ref(),
|
||||||
|
_ => &self.col_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ColumnDef> for Column {
|
impl From<ColumnDef> for Column {
|
||||||
|
@ -58,7 +58,8 @@ impl EntityTransformer {
|
|||||||
col
|
col
|
||||||
})
|
})
|
||||||
.map(|col| {
|
.map(|col| {
|
||||||
if let sea_query::ColumnType::Enum { name, variants } = &col.col_type {
|
if let sea_query::ColumnType::Enum { name, variants } = col.get_inner_col_type()
|
||||||
|
{
|
||||||
enums.insert(
|
enums.insert(
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
ActiveEnum {
|
ActiveEnum {
|
||||||
|
@ -461,7 +461,7 @@ impl EntityWriter {
|
|||||||
.columns
|
.columns
|
||||||
.iter()
|
.iter()
|
||||||
.fold(TokenStream::new(), |mut ts, col| {
|
.fold(TokenStream::new(), |mut ts, col| {
|
||||||
if let sea_query::ColumnType::Enum { name, .. } = &col.col_type {
|
if let sea_query::ColumnType::Enum { name, .. } = col.get_inner_col_type() {
|
||||||
let enum_name = format_ident!("{}", name.to_string().to_upper_camel_case());
|
let enum_name = format_ident!("{}", name.to_string().to_upper_camel_case());
|
||||||
ts.extend([quote! {
|
ts.extend([quote! {
|
||||||
use super::sea_orm_active_enums::#enum_name;
|
use super::sea_orm_active_enums::#enum_name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user