Skip to content

enums are always lowercased in queries despire enum_name leading to type does not exist #2087

@smndtrl

Description

@smndtrl

Description

After running the CLI to generate the types from my existing db, I got

#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ModuleType")]
pub enum ModuleType {
    #[sea_orm(string_value = "Sink")]
    Sink,
    #[sea_orm(string_value = "Source")]
    Source,
    #[sea_orm(string_value = "Transformation")]
    Transformation,
}

A simple query with it always results in a lowercase moduletype not existing - which is correct. The generator correctly extracted the type name with capitals.

Query(SqlxError(Database(PgDatabaseError { severity: Error, code: "42704", message: "type \"moduletype\" does not exist", detail: None, hint: None, position: Some(Original(65)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("parse_type.c"), line: Some(270), routine: Some("typenameType") })))

Steps to Reproduce

  1. Have a enum with capitals in it
  2. sea-orm-cli generate entity
  3. run any insert

Expected Behavior

inserts work

Actual Behavior

Query(SqlxError(Database(PgDatabaseError { severity: Error, code: "42704", message: "type \"moduletype\" does not exist", detail: None, hint: None, position: Some(Original(65)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("parse_type.c"), line: Some(270), routine: Some("typenameType") })))

Reproduces How Often

always

Workarounds

Reproducible Example

Versions

sea-orm v0.12.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions