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

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

Open
smndtrl opened this issue Jan 30, 2024 · 2 comments

Comments

@smndtrl
Copy link

smndtrl commented Jan 30, 2024

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

@imwexpex
Copy link

Hey! I'm facing the same issue, have you found a workaround?

@tyt2y3
Copy link
Member

tyt2y3 commented Mar 2, 2024

I am also unsure where the lowercase is being applied. If anyone have found it, a PR would be appreciated!

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

No branches or pull requests

3 participants