github SeaQL/sea-orm 2.0.3

latest release: sea-orm-cli@2.0.3
3 hours ago

SeaORM 2.0.3

(since 2.0.2)

Bug Fixes

  • Fix panics when using select_also / select_both with a column that requires a cast on select #3194

    A 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_site for 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 DeriveActiveEnum conflicting with an enum variant named Error #3185

    The generated TryFrom<&str> implementation used Self::Error in the return type of try_from. If the enum had a variant named Error, Self::Error would 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 Eq derive on ModelEx #3193

    Eq is deliberately not inherited from the model because a nested relation may contain fields that do not implement Eq.

    However, the previous derive filtering logic also discarded an Eq explicitly requested by the user.

    Explicit derives are now preserved, and the clippy::derive_partial_eq_without_eq warning caused by the missing Eq is 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_name connection URLs #3197

    sea-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"

Don't miss a new sea-orm release

NewReleases is sending notifications on new releases.