You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using PostgreSQL, a table that has two columns using the same enum causes the generated entity to have duplicate use statements, which cause a compilation error.
Steps to Reproduce
Create a migration like this:
use sea_orm_migration::prelude::*;use sea_orm_migration::prelude::extension::postgres::Type;use sea_orm_migration::sea_orm::DbBackend;#[derive(DeriveMigrationName)]pubstructMigration;#[async_trait::async_trait]implMigrationTraitforMigration{asyncfnup(&self,manager:&SchemaManager) -> Result<(),DbErr>{assert_eq!(manager.get_database_backend(),DbBackend::Postgres);
manager.create_type(Type::create().as_enum(MyEnum::Table).values([MyEnum::A,MyEnum::B]).to_owned()).await?;
manager
.create_table(Table::create().table(MyTable::Table).if_not_exists().col(ColumnDef::new(MyTable::Id).integer().not_null().auto_increment().primary_key(),).col(ColumnDef::new(MyTable::Col1).enumeration(MyEnum::Table,[MyEnum::A,MyEnum::B]).not_null()).col(ColumnDef::new(MyTable::Col2).enumeration(MyEnum::Table,[MyEnum::A,MyEnum::B]).not_null()).to_owned(),).await}asyncfndown(&self,manager:&SchemaManager) -> Result<(),DbErr>{
manager
.drop_table(Table::drop().table(MyTable::Table).to_owned()).await}}/// Learn more at https://docs.rs/sea-query#iden#[derive(Iden)]enumMyTable{Table,Id,Col1,Col2,}#[derive(Iden)]enumMyEnum{Table,A,B,}
Note: I tried to fix this and manage to solve it for my project where the bug originally showed up.
However, I would have liked to add some kind of tests for that but I didn't really understand how. - https://github.com/SeaQL/sea-orm/blob/master/CONTRIBUTING.md did state how to run all the tests (which were successful for my commit) but not how the test system works and where to add my own tests.
I currently don't have the time to try to understand how tests work, so unfortunately, I don't think it would be much help if I opened a PR myself (or would it?).
So if someone wants to pick this up - feel free to use my changes, the main thing that's missing is some test.
Reproducible Example
Currently, it does not seem like I will have time to add a PR for that unfortunately.
Versions
sea-orm-cli: master (1431d80)
Postgres (14.5 - should not matter)
Windows 10 (should not matter)
The text was updated successfully, but these errors were encountered:
Description
When using PostgreSQL, a table that has two columns using the same enum causes the generated entity to have duplicate
use
statements, which cause a compilation error.Steps to Reproduce
sea migrate
sea generate entity -o src/entities
src/entities/my_table.rs
)Expected Behavior
The generated file has only one import and compiles without errors.
Generated file should look like this:
Actual Behavior
Generated file has duplicate use statements and looks like this:
Reproduces How Often
Always
Workarounds
Manually remove the duplicate
use
statement each timeI've implemented a simple fix in 7cf3195
Note: I tried to fix this and manage to solve it for my project where the bug originally showed up.
However, I would have liked to add some kind of tests for that but I didn't really understand how. - https://github.com/SeaQL/sea-orm/blob/master/CONTRIBUTING.md did state how to run all the tests (which were successful for my commit) but not how the test system works and where to add my own tests.
I currently don't have the time to try to understand how tests work, so unfortunately, I don't think it would be much help if I opened a PR myself (or would it?).
So if someone wants to pick this up - feel free to use my changes, the main thing that's missing is some test.
Reproducible Example
Currently, it does not seem like I will have time to add a PR for that unfortunately.
Versions
The text was updated successfully, but these errors were encountered: