Skip to content

Enum column named "model" generates code that conflicts with the struct Model #2153

@junbl

Description

@junbl

Description

If I have a field named model that's an enum, sea-orm-cli will generate an enum in sea_orm_active_enums named Model which conflicts with the automatically generated struct Model.

Same issue occurs for a field named relation, active_model, entity, or column.

Steps to Reproduce

  1. Create a table like this:
create table model_example (
    id int unsigned primary key,
    model enum("A", "B", "C")
)
  1. Run sea-orm-cli to generate the code for this table

Expected Behavior

The CLI wouldn't generate code that fails to compile.

Actual Behavior

Both an enum Model and the struct Model are generated, causing a conflict in that file.

Reproduces How Often

Always reproducible.

Workarounds

You can of course just rename the enum manually.

Reproducible Example

Not sure best way to do this since the issue is with the autogenerated code and database setup, no user code.

Versions

├── sea-orm v0.12.1
│   ├── sea-orm-macros v0.12.1 (proc-macro)
│   │   ├── sea-bae v0.2.0 (proc-macro)
│   ├── sea-query v0.30.0
│   ├── sea-query-binder v0.5.0
│   │   ├── sea-query v0.30.0 (*)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions