Skip to content

postgres: CAST($2 AS CaseSensitiveEnumType) enum type must be enquoted #725

Closed
SeaQL/sea-orm
#2271
@niklaskorz

Description

@niklaskorz

Description

When a model contains a field with a case-sensitive enum type name, querying the table crashes because the type name is not enquoted in the CAST.

Steps to Reproduce

  1. Have a model field with a case-sensitive enum type name
  2. Query the model for rows with a specific value for this enum field

Expected Behavior

The query should not crash.

Actual Behavior

2023-12-18T11:15:22.411880Z  INFO JobScheduler::recover_jobs: sqlx::query: summary="SELECT \"KjuJob\".\"id\", \"KjuJob\".\"type\", \"KjuJob\".\"data\", …" db.statement="\n\nSELECT\n  \"KjuJob\".\"id\",\n  \"KjuJob\".\"type\",\n  \"KjuJob\".\"data\",\n  CAST(\"KjuJob\".\"state\" AS text),\n  \"KjuJob\".\"created\",\n  \"KjuJob\".\"updated\"\nFROM\n  \"KjuJob\"\nWHERE\n  \"KjuJob\".\"state\" = CAST($1 AS KjuJobState)\n  OR \"KjuJob\".\"state\" = CAST($2 AS KjuJobState)\n" rows_affected=0 rows_returned=0 elapsed=19.019766ms
Error: Query Error: error returned from database: type "kjujobstate" does not exist

All type names in this query are enquoted and thus case-sensitive, except in \"KjuJob\".\"state\" = CAST($2 AS KjuJobState).

Reproduces How Often

Every time

Versions

0.30.0

Additional Information

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