Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kingwingfly
Copy link
Contributor

PR Info

Bug Fixes

  • generating entity with --expanded-format for array of enum got a type mismatch error
error[E0308]: mismatched types
   --> entities/src/gen/foo.rs:<line>:<col>
    |
69  |             Self::FooBar => ColumnType::Array(RcOrArc::new(BarBaz::db_type())).def(),
    |                                              ------------ ^^^^^^^^^^^^^^^^^^^^^ expected `ColumnType`, found `ColumnDef`
    |                                              |
    |                                              arguments to this function are incorrect

Changes

@pranc1ngpegasus said db_type() should be column_type(), but column_type() needs to import ValueType trait. So I find column_type:

fn column_type() -> sea_orm::sea_query::ColumnType {
    <Self as sea_orm::ActiveEnum>::db_type()
        .get_column_type()
        .to_owned()
        .into()
}

So, I modified the code in sea-orm-codegen from

quote! { #enum_ident::db_type() }

to

quote! {
    #enum_ident::db_type()
        .get_column_type()
        .to_owned()
}

Hope this change did not influence other components...

Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

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

that's smart! yeah sorry we don't really recommend expanded entity format these days.
so if that works for you, it should be good

@tyt2y3 tyt2y3 merged commit 0058614 into SeaQL:master Mar 30, 2025
36 checks passed
@Expurple
Copy link
Member

Thank you!

@github-actions
Copy link

🎉 Released In 1.1.8 🎉

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

hjarraya pushed a commit to sambaclab/sea-orm that referenced this pull request Apr 29, 2025
* fix SeaQL#2409

* Refactor enum column type formatting for readability
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.

Generate entities: RcOrArc<ColumnDef> passed for ColumnType::Array

3 participants