Skip to content

feat: support schema_name on DeriveActiveEnum#3055

Open
nils-degroot wants to merge 2 commits intoSeaQL:masterfrom
nils-degroot:master
Open

feat: support schema_name on DeriveActiveEnum#3055
nils-degroot wants to merge 2 commits intoSeaQL:masterfrom
nils-degroot:master

Conversation

@nils-degroot
Copy link
Copy Markdown

Hiya. I'm running a database with many would like to specify where which enum lives. Currently a workaround would be to do something like enum_name = "some_schema\".\"some_enum". This PR adds a schema_name field to the DeriveActiveEnum to properly support this. By default it will be empty mirroring the current behavior.

PR Info

New Features

  • Add the schema_name field to DeriveActiveEnum

@Huliiiiii Huliiiiii requested a review from tyt2y3 April 28, 2026 13:35
Comment thread tests/active_enum_tests.rs Outdated
Comment thread tests/active_enum_tests.rs Outdated
Comment thread tests/active_enum_tests.rs Outdated
Comment thread sea-orm-macros/src/derives/active_enum.rs Outdated
Comment thread sea-orm-macros/src/derives/active_enum.rs Outdated
Comment thread sea-orm-macros/src/derives/active_enum.rs Outdated
Comment on lines +69 to +96

#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(
rs_type = "Enum",
db_type = "Enum",
enum_name = "mood",
schema_name = "my_schema"
)]
pub enum Mood {
#[sea_orm(string_value = "Happy")]
Happy,
#[sea_orm(string_value = "Sad")]
Sad,
}

#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "priority",
schema_name = "my_schema"
)]
pub enum Priority {
#[sea_orm(string_value = "Low")]
Low,
#[sea_orm(string_value = "High")]
High,
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why two enums are needed here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't need to be public. I've added them to the test file itself with the entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type "schema.x_enum" does not exist - after updating to SQLX 0.8.5

2 participants