SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
7.03k stars 493 forks source link

Auto Generated ActiveEnum String Values And Model Column Names #2170

Closed anshap1719 closed 4 months ago

anshap1719 commented 6 months ago

PR Info

New Features

Dependents

anshap1719 commented 6 months ago

@tyt2y3 @billy1624 Can I ask for your opinions for these:

anshap1719 commented 5 months ago

Hi @tyt2y3 @billy1624, sorry to ping you about this! Did you get a chance to look at it yet?

anshap1719 commented 5 months ago

@billy1624 This is ready for your review in my opinion.

anshap1719 commented 5 months ago

Thanks @billy1624

anshap1719 commented 4 months ago

@tyt2y3 Please review.

anshap1719 commented 4 months ago

@tyt2y3 @billy1624 Thanks for all your help as well.

github-actions[bot] commented 4 months ago

: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 ⭐.

IgnisDa commented 4 months ago

@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.

image

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
}
github-actions[bot] commented 1 month ago

: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 ⭐.