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

Not able to use Vec<Enum> in database #1163

Closed
mpu-mypl opened this issue Oct 27, 2022 · 1 comment · Fixed by #1210
Closed

Not able to use Vec<Enum> in database #1163

mpu-mypl opened this issue Oct 27, 2022 · 1 comment · Fixed by #1210
Assignees
Milestone

Comments

@mpu-mypl
Copy link

mpu-mypl commented Oct 27, 2022

Description

With the upgrade to version 0.10.1, we would need to use some Vec<Enum> with PostgreSQL.
Thanks by advance for help!

Steps to Reproduce

  1. Define an enum to use in a Model:
#[derive(DeriveActiveEnum)]
#[sea_orm(rs_type = "i32", db_type = "Integer")]
enum MyEnum {
    A = 1,
    B = 2,
}
  1. Integrate your enum as a column of Vec<MyEnum> in the model:
#[derive(DeriveEntityModel)]
#[sea_orm(table_name = "example")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub enums: Vec<MyEnum>,
}
  1. cargo check and the error should be thrown.

Expected Behavior

It is expected that with postgres-array feature enabled we could be able to use our numerical enum in arrays.

Actual Behavior

The compiler throws the following error:

   |
10 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize)]
   |                                   ^^^^^^^^^^^^^^^^^ the trait `sea_orm::sea_query::value::with_array::NotU8` is not implemented for `MyEnum`
   |
   = help: the following other types implement trait `sea_orm::sea_query::value::with_array::NotU8`:
             JsonValue
             NaiveDate
             NaiveDateTime
             NaiveTime
             Vec<u8>
             bool
             char
             chrono::DateTime<Tz>
           and 16 others
   = note: required because of the requirements on the impl of `From<Vec<MyEnum>>` for `sea_orm::Value`
   = note: required because of the requirements on the impl of `Into<sea_orm::Value>` for `Vec<MyEnum>`
note: required by a bound in `ActiveValue`

Reproduces How Often

Occur on compilation.

Versions

│   ├── sea-orm v0.10.1
│   │   ├── sea-orm-macros v0.10.1 (proc-macro)
│   │   ├── sea-query v0.27.1
│   │   │   ├── sea-query-derive v0.2.0 (proc-macro)
│   │   ├── sea-query-binder v0.2.1
│   │   │   ├── sea-query v0.27.1 (*)
│   │   ├── sea-strum v0.23.0
│   │   │   └── sea-strum_macros v0.23.0 (proc-macro)
│   │   ├── sea-orm v0.10.1 (*)
│   │   ├── sea-orm-migration v0.10.1
│   │   │   ├── sea-orm v0.10.1 (*)
│   │   │   ├── sea-orm-cli v0.10.1
│   │   │   │   ├── sea-schema v0.10.2
│   │   │   │   │   ├── sea-query v0.27.1 (*)
│   │   │   │   │   └── sea-schema-derive v0.1.0 (proc-macro)
│   │   │   ├── sea-schema v0.10.2 (*)
│   ├── sea-orm v0.10.1 (*)
├── sea-orm v0.10.1 (*)
├── sea-orm-migration v0.10.1 (*)

Additional Information

Check reproduction steps.

@billy1624 billy1624 self-assigned this Nov 8, 2022
@billy1624
Copy link
Member

billy1624 commented Nov 8, 2022

Hey @mpu-mypl, thanks for the report and sorry for the delay.

Vector of Postgres Enum was not supported at the moment. The PR #1210 should add the support for it.

@billy1624 billy1624 added this to the 0.10.x milestone Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants