Skip to content

Commit

Permalink
Hotfix: conditionally impl impl_try_getable_array
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Oct 23, 2023
1 parent e9acabd commit 42babea
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sea-orm-macros/src/derives/active_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,22 @@ impl ActiveEnum {
quote!()
};

let impl_try_getable_array = if cfg!(feature = "postgres-array") {
quote!(
#[automatically_derived]
impl sea_orm::TryGetableArray for #ident {
fn try_get_by<I: sea_orm::ColIdx>(res: &sea_orm::QueryResult, index: I) -> std::result::Result<Vec<Self>, sea_orm::TryGetError> {
<<Self as sea_orm::ActiveEnum>::Value as sea_orm::ActiveEnumValue>::try_get_vec_by(res, index)?
.into_iter()
.map(|value| <Self as sea_orm::ActiveEnum>::try_from_value(&value).map_err(Into::into))
.collect()
}
}
)
} else {
quote!()
};

quote!(
#[doc = " Generated by sea-orm-macros"]
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -337,15 +353,7 @@ impl ActiveEnum {
}
}

#[automatically_derived]
impl sea_orm::TryGetableArray for #ident {
fn try_get_by<I: sea_orm::ColIdx>(res: &sea_orm::QueryResult, index: I) -> std::result::Result<Vec<Self>, sea_orm::TryGetError> {
<<Self as sea_orm::ActiveEnum>::Value as sea_orm::ActiveEnumValue>::try_get_vec_by(res, index)?
.into_iter()
.map(|value| <Self as sea_orm::ActiveEnum>::try_from_value(&value).map_err(Into::into))
.collect()
}
}
#impl_try_getable_array

#[automatically_derived]
#[allow(clippy::from_over_into)]
Expand Down

0 comments on commit 42babea

Please sign in to comment.