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

sea-orm-cli generate --with-serde does not work on Postegresql custom type #581

Closed
fistons opened this issue Mar 4, 2022 · 2 comments · Fixed by #463
Closed

sea-orm-cli generate --with-serde does not work on Postegresql custom type #581

fistons opened this issue Mar 4, 2022 · 2 comments · Fixed by #463

Comments

@fistons
Copy link
Contributor

fistons commented Mar 4, 2022

Description

Using a Postgresql database, I have a custom type

CREATE TYPE user_role AS ENUM ('basic', 'admin');

I'm using sea-orm-cli generate entity --with-serde both -o entity/src to build my entities and my custom type entity does not derive
Serialize/Deserialize, preventing my other entity relying on it to build.

Steps to Reproduce

  1. Create an enum type in Postegresql
  2. Use this enum type in some other
  3. Generate your entity with sea-orm-cli generate entity --with-serde both -o entity/src
  4. Try to compile your project
  5. You can't :(

Expected Behavior

Here is the entity sea-orm-cli should build:

//! SeaORM Entity. Generated by sea-orm-codegen 0.6.0

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "user_role")]
pub enum UserRole {
    #[sea_orm(string_value = "admin")]
    Admin,
    #[sea_orm(string_value = "basic")]
    Basic,
}

Actual Behavior

Here is what is generated

//! SeaORM Entity. Generated by sea-orm-codegen 0.6.0

use sea_orm::entity::prelude::*;

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "user_role")]
pub enum UserRole {
    #[sea_orm(string_value = "admin")]
    Admin,
    #[sea_orm(string_value = "basic")]
    Basic,
}

Reproduces How Often

Always

Versions

sea-orm-cli 0.6.0
rustc 1.59.0 (9d1b2106e 2022-02-23)

@billy1624
Copy link
Member

Hey @fistons, thanks for reporting!

Related Issue & PR:

@billy1624 billy1624 linked a pull request Mar 14, 2022 that will close this issue
@billy1624
Copy link
Member

I'll close this issue as #463 was merged

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.

2 participants