sea-orm
sea-orm copied to clipboard
Auto Generated ActiveEnum String Values And Model Column Names
PR Info
- Closes #2160, #2125
New Features
- [x] Add support for
column_name_caseattribute inDeriveEntityModelfor automatically generating column names for all fields based on case style provided. - [x] Add support for
column_name_caseattribute in fields within a model that derivesDeriveEntityModelfor automatically generating column name based on case style provided. - [x] Add support for
rename_allattribute inDeriveActiveEnumfor automatically generating string values for all variants of the enum based on case style provided. - [x] Add support for
renameattribute for variants of anActiveEnumthat derivesDeriveActiveEnumfor automatically generating string value for it based on case style provided. - [x] Finalise names of newly added attributes.
- [x] Finalise allowed cases for column names
- [x] Finalise newly added error messages
- [x] Add documentation for new attributes
Dependents
- https://github.com/SeaQL/seaql.github.io/pull/121
@tyt2y3 @billy1624 Can I ask for your opinions for these:
- Finalise names of newly added attributes.
- Finalise allowed cases for column names
- Finalise newly added error messages
Hi @tyt2y3 @billy1624, sorry to ping you about this! Did you get a chance to look at it yet?
@billy1624 This is ready for your review in my opinion.
Thanks @billy1624
@tyt2y3 Please review.
@tyt2y3 @billy1624 Thanks for all your help as well.
:tada: Released In 1.0.0-rc.5 :tada:
Thank you everyone for the contribution! This feature is now available in the latest release. Now is a good time to upgrade! Your participation is what makes us unique; your adoption is what drives us forward. You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.
@anshap1719 Just wanted to inform you that this no longer works:
#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(
rs_type = "String",
db_type = "String(Some(1))",
rename_all = "camelCase"
)]
pub enum Category {
BigTask,
SmallWork,
}
String(None) does not work as well.
Using sea-orm 1.0.0-rc.5.
EDIT: Nvm found the correct way:
#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "camelCase")]
pub enum TestEnum {
DefaultVariant, // defaultVariant
#[sea_orm(rename = "kebab-case")]
VariantKebabCase, // variant-kebab-case
#[sea_orm(rename = "snake_case")]
VariantSnakeCase, // variant_snake_case
#[sea_orm(string_value = "CuStOmStRiNgVaLuE")]
CustomStringValue, // CuStOmStRiNgVaLuE
}
:tada: Released In 1.0.0 :tada:
Thank you everyone for the contribution! This feature is now available in the latest release. Now is a good time to upgrade! Your participation is what makes us unique; your adoption is what drives us forward. You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.