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
At least for Postgres (I have no experience with other databases) enums are ordered by definition order, but sea-orm-cli generate generates enums in alphabetical order. This is particularly problematic when I add --enum-extra-derives 'Ord,PartialOrd' --enum-extra-attributes 'repr(u32)' and now the rust-level comparison operator is not the same as the db-level comparison, and neither is the underlying u32 repr the same. This is also annoying if trying to use ActiveEnum::iter() but the ordering is not the meaningful order defined in the enum, but the alphabetical order of the Rust enum.
The Rust enum should match the order of the Postgres enum.
Actually, enum ordering differs across databases. See #2132. For SQLite, SeaORM emulates enums as strings and SQLite compares them alphabetically. So, the current Rust behavior is consistent with SQLite. I'm not sure which default makes more sense. This should probably be configurable.
Description
At least for Postgres (I have no experience with other databases) enums are ordered by definition order, but sea-orm-cli generate generates enums in alphabetical order. This is particularly problematic when I add
--enum-extra-derives 'Ord,PartialOrd' --enum-extra-attributes 'repr(u32)'
and now the rust-level comparison operator is not the same as the db-level comparison, and neither is the underlying u32 repr the same. This is also annoying if trying to useActiveEnum::iter()
but the ordering is not the meaningful order defined in the enum, but the alphabetical order of the Rust enum.Steps to Reproduce
sea-orm-cli generate entity -o ./entity --with-serde both --enum-extra-derives 'Copy,Ord,PartialOrd' --enum-extra-attributes 'repr(u32)'
Expected Behavior
The Rust enum should match the order of the Postgres enum.
Actual Behavior
The Rust enum is in alphabetical order.
Reproduces How Often
Always
Workarounds
Manually implement the enum separately.
Versions
Using
postgres:latest
in Docker on Mac.The text was updated successfully, but these errors were encountered: