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

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

Open
junbl opened this issue Mar 12, 2024 · 0 comments
Open

Comments

@junbl
Copy link
Contributor

junbl commented Mar 12, 2024

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 (*)
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

1 participant