SeaORM 2.0.3
(since 2.0.2)
Bug Fixes
-
Fix panics when using
select_also/select_bothwith a column that requires a cast on select #3194A combined select derives a prefixed alias for each selected expression. However, a cast expression is neither a plain column nor an enum cast, so previously its alias could not be derived, causing a panic.
Columns now carry their own aliases into the combined select, with the prefix applied on top.
Entity::find().select_also(other::Entity).build(DbBackend::Postgres) // before: panicked with "cannot apply alias for expr other than Column or AsEnum"
-- after SELECT "hello"."id" AS "A_id", CAST("hello"."two" AS integer) AS "A_two", ...
-
Use
Span::mixed_sitefor generated identifiers where possible to fix name shadowing issues in most cases #3185// did not compile before: `row` collided with a generated binding #[derive(FromQueryResult)] struct QueryResultProjection { row: String, }
-
Fix
DeriveActiveEnumconflicting with an enum variant namedError#3185The generated
TryFrom<&str>implementation usedSelf::Errorin the return type oftry_from. If the enum had a variant namedError,Self::Errorwould resolve to that variant instead of the associated type.The implementation now explicitly uses
sea_orm::DbErr.#[derive(DeriveActiveEnum)] enum ErrorVariantEnum { Error, // no longer breaks the generated `TryFrom<&str>` }
-
Avoid filtering out an explicitly requested
Eqderive onModelEx#3193Eqis deliberately not inherited from the model because a nested relation may contain fields that do not implementEq.However, the previous derive filtering logic also discarded an
Eqexplicitly requested by the user.Explicit derives are now preserved, and the
clippy::derive_partial_eq_without_eqwarning caused by the missingEqis suppressed.#[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "user", model_ex_attrs(derive(Eq)))] pub struct Model { #[sea_orm(primary_key)] pub id: i32, } // ModelEx now derives Eq
-
Skip code generation for partial indexes #3196
Partial indexes are not yet supported, so they are now skipped during code generation to avoid generating incorrect constraints.
CREATE UNIQUE INDEX login_human_login_id_key ON login (human_login_id) WHERE human_login_id IS NOT NULL; -- no longer emits #[sea_orm(unique)]
-
Support
postgres:db_nameconnection URLs #3197sea-orm-cli generate entity -u postgres:my_db -o src/entities
Compatibility Notes
-
#3194 also changes the generated SQL for regular queries.
Assertions on the generated SQL need to be updated.
-- Entity::find(), before SELECT "hello"."id", CAST("hello"."two" AS integer), "hello"."three3" FROM "hello" -- after SELECT "hello"."id", CAST("hello"."two" AS integer) AS "two", "hello"."three3" FROM "hello"