版本发布 8
* Add missing lifetime hint to `EntityName::table_name` (#2907) * [sea-orm-cli] Fix codegen to not generate relations to filtered entities (#2913) * [sea-orm-cli] Fix enum variants starting with digits (#2905) * Add wrapper type for storing Uuids as TEXT (#2914) * Optimize exists; `PaginatorTrait::exists` is moved to `SelectExt` (#2909) * Add tracing spans for database operations (#2885) * Fix derive enums without per-case rename (#2922) * Fix DeriveIntoActiveModel (#2926) ```rust #[derive(DeriveIntoActiveModel)] #[sea_orm(active_model = "<fruit::Entity as EntityTrait>::ActiveModel")] struct PartialFruit { cake_id: Option<i32>, } assert_eq!( PartialFruit { cake_id: Some(1) }.into_active_model(), fruit::ActiveModel { id: NotSet, name: NotSet, cake_id: Set(Some(1)), } ); ``` * FromQueryResult now supports nullable left join (#2845) ```rust #[derive(FromQueryResult)] struct CakeWithOptionalBakeryModel { #[sea_orm(alias = "cake_id")] id: i32, #[sea_orm(alias = "cake_name")] name: String, #[sea_orm(nested)] bakery: Option<bakery::Model>, } ```
### Enhancements * Add `find_linked_recursive` method to ModelTrait https://github.com/SeaQL/sea-orm/pull/2480 * Skip drop extension type in fresh https://github.com/SeaQL/sea-orm/pull/2716 ### Bug Fixes * Handle null values in `from_sqlx_*_row_to_proxy_row` functions https://github.com/SeaQL/sea-orm/pull/2744
### Bug Fixes * Fix enum casting in DerivePartialModel https://github.com/SeaQL/sea-orm/pull/2719 https://github.com/SeaQL/sea-orm/pull/2720 ```rust #[derive(DerivePartialModel)] #[sea_orm(entity = "active_enum::Entity", from_query_result, alias = "zzz")] struct PartialWithEnumAndAlias { #[sea_orm(from_col = "tea")] foo: Option<Tea>, } let sql = active_enum::Entity::find() .into_partial_model::<PartialWithEnumAndAlias>() .into_statement(DbBackend::Postgres) .sql; assert_eq!( sql, r#"SELECT CAST("zzz"."tea" AS "text") AS "foo" FROM "public"."active_enum""#, ); ``` ### Enhancements * [sea-orm-cli] Use tokio (optional) instead of async-std https://github.com/SeaQL/sea-orm/pull/2721
### Enhancements * Allow `DerivePartialModel` to have nested aliases https://github.com/SeaQL/sea-orm/pull/2686 ```rust #[derive(DerivePartialModel)] #[sea_orm(entity = "bakery::Entity", from_query_result)] struct Factory { id: i32, #[sea_orm(from_col = "name")] plant: String, } #[derive(DerivePartialModel)] #[sea_orm(entity = "cake::Entity", from_query_result)] struct CakeFactory { id: i32, name: String, #[sea_orm(nested, alias = "factory")] // <- new bakery: Option<Factory>, } ``` * Add `ActiveModelTrait::try_set` https://github.com/SeaQL/sea-orm/pull/2706 ```rust fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value); /// New: a non-panicking version of above fn try_set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value) -> Result<(), DbErr>; ``` ### Bug Fixes * [sea-orm-cli] Fix compilation issue https://github.com/SeaQL/sea-orm/pull/2713
## 1.1.14 - 2025-07-21 ### Enhancements * [sea-orm-cli] Mask sensitive ENV values https://github.com/SeaQL/sea-orm/pull/2658 ### Bug Fixes * `FromJsonQueryResult`: panic on serialization failures https://github.com/SeaQL/sea-orm/pull/2635 ```rust #[derive(Clone, Debug, PartialEq, Deserialize, FromJsonQueryResult)] pub struct NonSerializableStruct; impl Serialize for NonSerializableStruct { fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { Err(serde::ser::Error::custom( "intentionally failing serialization", )) } } let model = Model { json: Some(NonSerializableStruct), }; let _ = model.into_active_model().insert(&ctx.db).await; // panic here ```
* [sea-orm-cli] New `--frontend-format` flag to generate entities in pure Rust https://github.com/SeaQL/sea-orm/pull/2631 ```rust // for example, below is the normal (compact) Entity: use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] #[serde(skip_deserializing)] pub id: i32, #[sea_orm(column_type = "Text", nullable)] pub name: Option<String> , } // this is the generated frontend model, there is no SeaORM dependency: use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Model { #[serde(skip_deserializing)] pub id: i32, pub name: Option<String> , } ```
### New Features * [sea-orm-cli] New `--frontend-format` flag to generate entities in pure Rust: ```rust // for example, below is the normal (compact) Entity: use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] #[serde(skip_deserializing)] pub id: i32, #[sea_orm(column_type = "Text", nullable)] pub name: Option<String> , } // this is the generated frontend model, there is no SeaORM dependency: use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Model { #[serde(skip_deserializing)] pub id: i32, pub name: Option<String> , } ``` ### Enhancements * Remove potential panics in `Loader` https://github.com/SeaQL/sea-orm/pull/2637
### Enhancements * Make sea-orm-cli & sea-orm-migration dependencies optional https://github.com/SeaQL/sea-orm/pull/2367 * Relax TransactionError's trait bound for errors to allow `anyhow::Error` https://github.com/SeaQL/sea-orm/pull/2602 ### Bug Fixes * Include custom `column_name` in DeriveColumn `Column::from_str` impl https://github.com/SeaQL/sea-orm/pull/2603 ```rust #[derive(DeriveEntityModel)] pub struct Model { #[sea_orm(column_name = "lAsTnAmE")] last_name: String, } assert!(matches!(Column::from_str("lAsTnAmE").unwrap(), Column::LastName)); ```