Skip to content
Discussion options

You must be logged in to vote

You can do it with --enum-extra-attributes, without touching the generated file:

sea-orm-cli generate entity ... --enum-extra-attributes 'sea_orm(rs_type = "String")'

The generator always writes rs_type = "Enum" (active_enum.rs), but extra attributes go on the line right after it. DeriveActiveEnum reads every #[sea_orm(...)] on the enum in order and the later rs_type overwrites the earlier one (derives/active_enum.rs). With db_type = "Enum", String is one of the two allowed values.

I compiled this against current main (2.0.4) and Action::AutoHide.to_value() returned a String ("auto_hide"):

#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "Enum", db_ty…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@opeolluwa
Comment options

Answer selected by opeolluwa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants