Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Defaulting string_value For ActiveEnum Based On Renaming Rules On Variants #2160

Open
anshap1719 opened this issue Mar 16, 2024 Discussed in #2125 · 1 comment · May be fixed by #2170
Open

Allow Defaulting string_value For ActiveEnum Based On Renaming Rules On Variants #2160

anshap1719 opened this issue Mar 16, 2024 Discussed in #2125 · 1 comment · May be fixed by #2170

Comments

@anshap1719
Copy link
Sponsor Contributor

Discussed in #2125

Originally posted by wyatt-herkamp March 1, 2024
Take the following enum. I think we should automatically use the Variant name if the string_value is not provided.

#[derive(DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "Interval")]
pub enum Intervals {
    #[sea_orm(string_value = "Weekly")]
    Weekly,
    #[sea_orm(string_value = "BIWeekly")]
    BIWeekly,
    #[sea_orm(string_value = "Monthly")]
    Monthly,
    #[sea_orm(string_value = "Quarterly")]
    Quarterly,
    #[sea_orm(string_value = "Yearly")]
    Yearly,
}

This would allow people to do

#[derive(DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "Interval")]
pub enum Intervals {
    Weekly,
    BIWeekly,
    Monthly,
    Quarterly,
    Yearly,
}

And get the same result. I would be happy to make a PR if the developers of the project is Ok with this feature.

anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 16, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 16, 2024
@anshap1719
Copy link
Sponsor Contributor Author

@tyt2y3 While I was working on this, it made sense to also have this for model structs, so i decided to add that in (will be pushing later today). Let me know if there are any arguments against that.

anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Mar 22, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 25, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 25, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 25, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 25, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 25, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/sea-orm that referenced this issue Apr 26, 2024
anshap1719 added a commit to anshap1719/seaql.github.io that referenced this issue Apr 28, 2024
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 a pull request may close this issue.

1 participant