SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.57k stars 461 forks source link

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

Open junbl opened 3 months ago

junbl commented 3 months ago

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")
    )
  2. 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 (*)