-
-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Description
When generating entities through sea-orm-cli for a Postgres database, I realized that my enums in sea_orm_active_enums.rs have duplicated members:
pub enum Test {
#[sea_orm(string_value = "A")]
A,
#[sea_orm(string_value = "A")]
A,
#[sea_orm(string_value = "B")]
B,
#[sea_orm(string_value = "B")]
B,
}Obviously, this blocks the project from compiling. The root cause seems to be that my DB contains two distinct schemas with the same enums. When I delete one of the schemas and try again, the duplicates are gone.
Steps to Reproduce
- Create a Postgres DB with two schemas
s0ands1. - Create enums with the same name and members in both schemas (e.g.
s0.Testands1.Test). - Generate
sea-ormbindings for eithers0ors1.
Expected Behavior
The generated enums are restricted to the chosen schema and contain no duplicate members.
Actual Behavior
The generated enums are mixed up across schemas.
Additional Information
I suspect that the problem originates from sea_schema::postgres::query::enumeration::SchemaQueryBuilder::query_enums:
| pub fn query_enums(&self) -> SelectStatement { |
The query in this method is not restricted to a schema. A possible solution:
- Add a join to
pg_namespaceonpg_namespace.oid = pg_type.typnamespace - Filter by
pg_namespace.nspname = <schema>
Metadata
Metadata
Assignees
Labels
No labels