github SeaQL/sea-orm 2.0.4

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

SeaORM 2.0.4

(since 2.0.3)

Enhancements

  • Add select_except to select all columns except the given ones #3211

    select_except provides the inverse of select_only / column——selecting all columns except the specified ones.

    These methods replace the current selection, so the last one called takes effect.

    #[derive(DerivePartialModel)]
    #[sea_orm(entity = "post::Entity")]
    struct PostPreview {
        id: i32,
        title: String,
    }
    
    let posts = post::Entity::find()
        .select_except([post::Column::Body])
        .into_model::<PostPreview>()
        .all(db)
        .await?;

Bug Fixes

  • Fix chained left_join_linked using the wrong alias for links with multiple relations #3199

    When left_join_linked was called more than once, later joins in a multi-relation link could refer to aliases belonging to the first call. The query remained valid but could return incorrect rows.

    cake::Entity::find()
        .left_join_linked(CakeToFilling)
        .left_join_linked(CakeToFillingVendor)
    -- before
    LEFT JOIN `filling` AS `r3` ON `r0`.`filling_id` = `r3`.`id`
    
    -- after
    LEFT JOIN `filling` AS `r3` ON `r2`.`filling_id` = `r3`.`id`
  • Respect condition_type in linked joins #3203

    left_join_linked and find_linked always combined the relation condition and on_condition with AND, even when ConditionType::Any was specified.

    They now follow condition_type, matching regular join().

    cake::Relation::Fruit
        .def()
        .condition_type(ConditionType::Any)
        .on_condition(|_left, right| {
            Expr::col((right, fruit::Column::Name))
                .like("%tropical%")
                .into_condition()
        })
    -- before
    LEFT JOIN `fruit` AS `r0` ON `cake`.`id` = `r0`.`cake_id` AND `r0`.`name` LIKE '%tropical%'
    
    -- after
    LEFT JOIN `fruit` AS `r0` ON `cake`.`id` = `r0`.`cake_id` OR `r0`.`name` LIKE '%tropical%'
  • Fix save_as not being applied to array values in eq_any / ne_all #3208

    #[sea_orm(column_type = r#"custom("citext")"#, save_as = "citext")]
    pub email: String,
    
    Entity::find().filter(Column::Email.eq_any(["a@x.com".to_owned(), "B@x.com".to_owned()]))
    -- before: text[], case-sensitive
    WHERE "user"."email" = ANY(ARRAY ['a@x.com','B@x.com'])
    
    -- after
    WHERE "user"."email" = ANY(CAST(ARRAY ['a@x.com','B@x.com'] AS citext[]))
  • Fix schema sync failing to drop a stale unique index on MySQL #3202

    Removing #[sea_orm(unique)] from a column could make the next schema sync fail with MySQL error 1064.

Upgrades

  • Upgrade arrow to 60 (sea-orm-arrow 2.0.0-rc.5)

    with-arrow now builds against arrow 60. Arrow types passed to SeaORM, such as a RecordBatch for from_arrow, must come from arrow 60 too, so crates like parquet need the matching version.

    arrow = "60"
    parquet = "60"

Don't miss a new sea-orm release

NewReleases is sending notifications on new releases.