Releases: SeaQL/sea-orm
Releases · SeaQL/sea-orm
1.1.17
New Features
- Added
map_sqlx_mysql_opts
,map_sqlx_postgres_opts
,map_sqlx_sqlite_opts
toConnectOptions
#2731
let mut opt = ConnectOptions::new(url);
opt.map_sqlx_postgres_opts(|pg_opt: PgConnectOptions| {
pg_opt.ssl_mode(PgSslMode::Require)
});
1.1.16
Bug Fixes
#[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 #2721
1.1.15
Enhancements
- Allow
DerivePartialModel
to have nested aliases #2686
#[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
#2706
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 #2713
1.1.14
1.1.14 - 2025-07-21
Enhancements
- [sea-orm-cli] Mask sensitive ENV values #2658
Bug Fixes
FromJsonQueryResult
: panic on serialization failures #2635
#[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
1.1.13
New Features
- [sea-orm-cli] New
--frontend-format
flag to generate entities in pure Rust #2631
// 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
#2637
1.1.12
Enhancements
- Make sea-orm-cli & sea-orm-migration dependencies optional #2367
- Relax TransactionError's trait bound for errors to allow
anyhow::Error
#2602
Bug Fixes
- Include custom
column_name
in DeriveColumnColumn::from_str
impl #2603
#[derive(DeriveEntityModel)]
pub struct Model {
#[sea_orm(column_name = "lAsTnAmE")]
last_name: String,
}
assert!(matches!(Column::from_str("lAsTnAmE").unwrap(), Column::LastName));
1.1.11
Enhancements
- Added
ActiveModelTrait::default_values
assert_eq!(
fruit::ActiveModel::default_values(),
fruit::ActiveModel {
id: Set(0),
name: Set("".into()),
cake_id: Set(None),
type_without_default: NotSet,
},
);
- Impl
IntoCondition
forRelationDef
#2587
// This allows using `RelationDef` directly where sea-query expects an `IntoCondition`
let query = Query::select()
.from(fruit::Entity)
.inner_join(cake::Entity, fruit::Relation::Cake.def())
.to_owned();
- Loader: retain only unique key values in the query condition #2569
- Add proxy transaction impl #2573
- [sea-orm-cli] Fix
PgVector
codegen #2589
Bug fixes
- Quote type properly in
AsEnum
casting #2570
assert_eq!(
lunch_set::Entity::find()
.select_only()
.column(lunch_set::Column::Tea)
.build(DbBackend::Postgres)
.to_string(),
r#"SELECT CAST("lunch_set"."tea" AS "text") FROM "lunch_set""#
// "text" is now quoted; will work for "text"[] as well
);
- Fix unicode string enum #2218
Upgrades
- Upgrade
heck
to0.5
#2218 - Upgrade
sea-query
to0.32.5
- Upgrade
sea-schema
to0.16.2
1.1.10
1.1.9
Enhancements
- [sea-orm-macros] Use fully-qualified syntax for ActiveEnum associated type #2552
- Accept
LikeExpr
inlike
andnot_like
#2549
Bug fixes
- Check if url is well-formed before parsing #2558
QuerySelect::column_as
method cast ActiveEnum column #2551
House keeping
- Remove redundant
Expr::expr
from internal code #2554
1.1.8
New Features
- Implement
DeriveValueType
for enum strings
#[derive(DeriveValueType)]
#[sea_orm(value_type = "String")]
pub enum Tag {
Hard,
Soft,
}
// `from_str` defaults to `std::str::FromStr::from_str`
impl std::str::FromStr for Tag {
type Err = sea_orm::sea_query::ValueTypeErr;
fn from_str(s: &str) -> Result<Self, Self::Err> { .. }
}
// `to_str` defaults to `std::string::ToString::to_string`.
impl std::fmt::Display for Tag {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. }
}
// you can override from_str and to_str with custom functions
#[derive(DeriveValueType)]
#[sea_orm(value_type = "String", from_str = "Tag::from_str", to_str = "Tag::to_str")]
pub enum Tag {
Color,
Grey,
}
impl Tag {
fn from_str(s: &str) -> Result<Self, ValueTypeErr> { .. }
fn to_str(&self) -> &'static str { .. }
}
- Support Postgres Ipnetwork (under feature flag
with-ipnetwork
) #2395
// Model
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "host_network")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub ipaddress: IpNetwork,
#[sea_orm(column_type = "Cidr")]
pub network: IpNetwork,
}
// Schema
sea_query::Table::create()
.table(host_network::Entity)
.col(ColumnDef::new(host_network::Column::Id).integer().not_null().auto_increment().primary_key())
.col(ColumnDef::new(host_network::Column::Ipaddress).inet().not_null())
.col(ColumnDef::new(host_network::Column::Network).cidr().not_null())
.to_owned();
// CRUD
host_network::ActiveModel {
ipaddress: Set(IpNetwork::new(Ipv6Addr::new(..))),
network: Set(IpNetwork::new(Ipv4Addr::new(..))),
..Default::default()
}
Enhancements
- Added
try_getable_postgres_array!(Vec<u8>)
(to supportbytea[]
) #2503
Bug fixes
- [sea-orm-codegen] Support postgres array in expanded format #2545
House keeping
- Replace
once_cell
crate withstd
equivalent #2524
(available since rust 1.80)