Skip to content

Enum imports duplicated when merging grouped and individual use statements #2947

@lmurri

Description

@lmurri

Description

When regenerating entities with sea-orm-cli generate entity --expanded-format and preserve_user_modifications enabled, enum imports can be duplicated if the existing file uses grouped imports and the newly generated output uses individual imports.

This results in semantically duplicate use statements being emitted.

Steps to Reproduce

  1. Generate entities with:
   sea-orm-cli generate entity --expanded-format
  1. Modify the generated file to group enum imports, e.g.:
   use super::sea_orm_active_enums::{Status, Category};
  1. Re-run entity generation with preserve_user_modifications enabled.
  2. Observe the merged output.

Expected Behavior

Only one import per enum path should exist in the merged output, e.g.:

use super::sea_orm_active_enums::Status;
use super::sea_orm_active_enums::Category;

(or the grouped form, but not both).

Actual Behavior

The merge produces duplicate imports:

use super::sea_orm_active_enums::{Status, Category};
use super::sea_orm_active_enums::Status;
use super::sea_orm_active_enums::Category;

Reproduces How Often

Always, given the grouped → individual import transition.

Workarounds

delete all generated code before generation

Versions

  • sea-orm-cli: 2.0.0-rc.30
  • sea-orm-codegen: 2.0.0-rc.30
  • OS: macOS (also reproducible on Linux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions