NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #1946 most downloaded on crates.io
Derive macros for SeaORM
Last release 4 days ago
13 Sep 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 57 of the last 60 stable releases
3 versions withdrawn
withdrawn after publishing
5 years old
134 releases · first in 2021
One column per quarter.
Implement DeriveValueType for enum strings ```rust
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 { .. }
}
with-ipnetwork) https://github.com/SeaQL/sea-orm/pull/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()
}
try_getable_postgres_array!(Vec<u8>) (to support bytea[]) https://github.com/SeaQL/sea-orm/pull/2503once_cell crate with std equivalent https://github.com/SeaQL/sea-orm/pull/2524
(available since rust 1.80)Support nested entities in FromQueryResult https://github.com/SeaQL/sea-orm/pull/2508 ```rust
FromQueryResult https://github.com/SeaQL/sea-orm/pull/2508#[derive(FromQueryResult)]
struct Cake {
id: i32,
name: String,
#[sea_orm(nested)]
bakery: Option<CakeBakery>,
}
#[derive(FromQueryResult)]
struct CakeBakery {
#[sea_orm(from_alias = "bakery_id")]
id: i32,
#[sea_orm(from_alias = "bakery_name")]
title: String,
}
let cake: Cake = cake::Entity::find()
.select_only()
.column(cake::Column::Id)
.column(cake::Column::Name)
.column_as(bakery::Column::Id, "bakery_id")
.column_as(bakery::Column::Name, "bakery_name")
.left_join(bakery::Entity)
.order_by_asc(cake::Column::Id)
.into_model()
.one(&ctx.db)
.await?
.unwrap();
assert_eq!(
cake,
Cake {
id: 1,
name: "Cake".to_string(),
bakery: Some(CakeBakery {
id: 20,
title: "Bakery".to_string(),
})
}
);
DerivePartialModel https://github.com/SeaQL/sea-orm/pull/2508#[derive(DerivePartialModel)] // FromQueryResult is no longer needed
#[sea_orm(entity = "cake::Entity", from_query_result)]
struct Cake {
id: i32,
name: String,
#[sea_orm(nested)]
bakery: Option<Bakery>,
}
#[derive(DerivePartialModel)]
#[sea_orm(entity = "bakery::Entity", from_query_result)]
struct Bakery {
id: i32,
#[sea_orm(from_col = "Name")]
title: String,
}
// same as previous example, but without the custom selects
let cake: Cake = cake::Entity::find()
.left_join(bakery::Entity)
.order_by_asc(cake::Column::Id)
.into_partial_model()
.one(&ctx.db)
.await?
.unwrap();
assert_eq!(
cake,
Cake {
id: 1,
name: "Cake".to_string(),
bakery: Some(CakeBakery {
id: 20,
title: "Bakery".to_string(),
})
}
);
IntoActiveModel with DerivePartialModel https://github.com/SeaQL/sea-orm/pull/2517#[derive(DerivePartialModel)]
#[sea_orm(entity = "cake::Entity", into_active_model)]
struct Cake {
id: i32,
name: String,
}
assert_eq!(
Cake {
id: 12,
name: "Lemon Drizzle".to_owned(),
}
.into_active_model(),
cake::ActiveModel {
id: Set(12),
name: Set("Lemon Drizzle".to_owned()),
..Default::default()
}
);
SelectThree https://github.com/SeaQL/sea-orm/pull/2518// Order -> (many) Lineitem -> Cake
let items: Vec<(order::Model, Option<lineitem::Model>, Option<cake::Model>)> =
order::Entity::find()
.find_also_related(lineitem::Entity)
.and_also_related(cake::Entity)
.order_by_asc(order::Column::Id)
.order_by_asc(lineitem::Column::Id)
.all(&ctx.db)
.await?;
DeriveIntoActiveModel https://github.com/SeaQL/sea-orm/pull/2517#[derive(DeriveIntoActiveModel)]
#[sea_orm(active_model = "<fruit::Entity as EntityTrait>::ActiveModel")]
struct Fruit {
cake_id: Option<Option<i32>>,
}
DatabaseConnection::close_by_ref https://github.com/SeaQL/sea-orm/pull/2511pub async fn close(self) -> Result<(), DbErr> { .. } // existing
pub async fn close_by_ref(&self) -> Result<(), DbErr> { .. } // new
ActiveValue::Set https://github.com/SeaQL/sea-orm/pull/2515Support PgVector (under feature flag postgres-vector) https://github.com/SeaQL/sea-orm/pull/2500 ```rust // Model
postgres-vector) https://github.com/SeaQL/sea-orm/pull/2500// Model
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "image_model")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: i32,
pub embedding: PgVector,
}
// Schema
sea_query::Table::create()
.table(image_model::Entity.table_ref())
.col(ColumnDef::new(Column::Id).integer().not_null().primary_key())
.col(ColumnDef::new(Column::Embedding).vector(None).not_null())
..
// Insert
ActiveModel {
id: NotSet,
embedding: Set(PgVector::from(vec![1., 2., 3.])),
}
.insert(db)
.await?
Insert::exec_with_returning_keys & Insert::exec_with_returning_many (Postgres only)assert_eq!(
Entity::insert_many([
ActiveModel { id: NotSet, name: Set("two".into()) },
ActiveModel { id: NotSet, name: Set("three".into()) },
])
.exec_with_returning_many(db)
.await
.unwrap(),
[
Model { id: 2, name: "two".into() },
Model { id: 3, name: "three".into() },
]
);
assert_eq!(
cakes_bakers::Entity::insert_many([
cakes_bakers::ActiveModel {
cake_id: Set(1),
baker_id: Set(2),
},
cakes_bakers::ActiveModel {
cake_id: Set(2),
baker_id: Set(1),
},
])
.exec_with_returning_keys(db)
.await
.unwrap(),
[(1, 2), (2, 1)]
);
DeleteOne::exec_with_returning & DeleteMany::exec_with_returning https://github.com/SeaQL/sea-orm/pull/2432sqlx::postgres::PgRow) https://github.com/SeaQL/sea-orm/pull/2265acquire-timeout option https://github.com/SeaQL/sea-orm/pull/2461with-prelude option https://github.com/SeaQL/sea-orm/pull/2322impl-active-model-behavior option https://github.com/SeaQL/sea-orm/pull/2487seaography::register_active_enums macro https://github.com/SeaQL/sea-orm/pull/2475futures crate, replace with futures-util https://github.com/SeaQL/sea-orm/pull/2466Added Schema::json_schema_from_entity to construct a schema description in json for the given Entity
Schema::json_schema_from_entity to construct a schema description in json for the given EntityAllow modifying the connection in migrations https://github.com/SeaQL/sea-orm/pull/2397
DeriveRelatedEntity proc_macro use async-graphql re-exported by seaography https://github.com/SeaQL/sea-orm/pull/2469[sea-orm-codegen] register seaography entity modules & active enums https://github.com/SeaQL/sea-orm/pull/2403 ```rust pub mod prelude;
pub mod prelude;
pub mod sea_orm_active_enums;
pub mod baker;
pub mod bakery;
pub mod cake;
pub mod cakes_bakers;
pub mod customer;
pub mod lineitem;
pub mod order;
seaography::register_entity_modules!([
baker,
bakery,
cake,
cakes_bakers,
customer,
lineitem,
order,
]);
seaography::register_active_enums!([
sea_orm_active_enums::Tea,
sea_orm_active_enums::Color,
]);
// this previously panics
let apple = cake_filling::ActiveModel {
cake_id: ActiveValue::set(2),
filling_id: ActiveValue::NotSet,
};
let orange = cake_filling::ActiveModel {
cake_id: ActiveValue::NotSet,
filling_id: ActiveValue::set(3),
};
assert_eq!(
Insert::<cake_filling::ActiveModel>::new()
.add_many([apple, orange])
.build(DbBackend::Postgres)
.to_string(),
r#"INSERT INTO "cake_filling" ("cake_id", "filling_id") VALUES (2, NULL), (NULL, 3)"#,
);
MIGRATION_DIR environment variable https://github.com/SeaQL/sea-orm/pull/2419ColumnDef::is_unique https://github.com/SeaQL/sea-orm/pull/2401search_path https://github.com/SeaQL/sea-orm/pull/2436Added ColumnTrait::enum_type_name() to signify enum types https://github.com/SeaQL/sea-orm/pull/2415
ColumnTrait::enum_type_name() to signify enum types https://github.com/SeaQL/sea-orm/pull/2415DbBackend::boolean_value() for database dependent boolean value https://github.com/SeaQL/sea-orm/pull/2415[sea-orm-macros] impl From for ActiveModel instead of impl From< ::Model> for ActiveModel https://github.com/SeaQL/sea-orm/pull/2349. Now the followin
impl From<Model> for ActiveModel instead of impl From<<Entity as sea_orm::EntityTrait>::Model> for ActiveModel https://github.com/SeaQL/sea-orm/pull/2349.
Now the following can compile:use sea_orm::{tests_cfg::cake, Set};
struct Cake {
id: i32,
name: String,
}
impl From<Cake> for cake::ActiveModel {
fn from(value: Cake) -> Self {
Self {
id: Set(value.id),
name: Set(value.name),
}
}
}
[sea-orm-macros] Call EnumIter::get using fully qualified syntax https://github.com/SeaQL/sea-orm/pull/2321
1.1.0-rc.1: 2024-08-091.1.0-rc.2: 2024-10-041.1.0-rc.3: 2024-10-08EnumIter::get using fully qualified syntax https://github.com/SeaQL/sea-orm/pull/2321DatabaseConnection directly from sqlx::PgPool, sqlx::SqlitePool and sqlx::MySqlPool https://github.com/SeaQL/sea-orm/pull/2348pk_uuid schema helper https://github.com/SeaQL/sea-orm/pull/2329custom and custom_null schema helper to take column name and alias of different IntoIden types https://github.com/SeaQL/sea-orm/pull/2326ColumnDef::get_column_default getter https://github.com/SeaQL/sea-orm/pull/2387sqlx to 0.8.2 https://github.com/SeaQL/sea-orm/pull/2305, https://github.com/SeaQL/sea-orm/pull/2371bigdecimal to 0.4 https://github.com/SeaQL/sea-orm/pull/2305sea-query to 0.32.0-rc https://github.com/SeaQL/sea-orm/pull/2305sea-query-binder to 0.7.0-rc https://github.com/SeaQL/sea-orm/pull/2305sea-schema to 0.16.0-rc https://github.com/SeaQL/sea-orm/pull/2305ouroboros to 0.18 https://github.com/SeaQL/sea-orm/pull/2353Nothing published for this version
Nothing published for this version
Nothing published for this version
Changed ProxyDatabaseTrait methods to async. It's a breaking change, but it should have been part of the 1.0 release. The feature is behind the featur…
ConnectOptions::connect_lazy for creating DB connection pools without establishing connections up front https://github.com/SeaQL/sea-orm/pull/2268ProxyDatabaseTrait methods to async. It's a breaking change, but it should have been part of the 1.0 release.
The feature is behind the feature guard proxy, and we believe it shouldn't impact majority of users.
https://github.com/SeaQL/sea-orm/pull/2278ColumnType to Rust type resolution https://github.com/SeaQL/sea-orm/pull/2313Introduce PrimaryKeyArity with ARITY constant https://github.com/SeaQL/sea-orm/pull/2185 `rust fn get_arity_of () -> usize { E::PrimaryKey::iter().cou
1.0.0-rc.1: 2024-02-061.0.0-rc.2: 2024-03-151.0.0-rc.3: 2024-03-261.0.0-rc.4: 2024-05-131.0.0-rc.5: 2024-05-291.0.0-rc.6: 2024-06-191.0.0-rc.7: 2024-06-25PrimaryKeyArity with ARITY constant https://github.com/SeaQL/sea-orm/pull/2185fn get_arity_of<E: EntityTrait>() -> usize {
E::PrimaryKey::iter().count() // before; runtime
<<E::PrimaryKey as PrimaryKeyTrait>::ValueType as PrimaryKeyArity>::ARITY // now; compile-time
}
ActiveModel to EntityTrait https://github.com/SeaQL/sea-orm/pull/2186rename_all attribute to DeriveEntityModel & DeriveActiveEnum https://github.com/SeaQL/sea-orm/pull/2170#[derive(DeriveEntityModel)]
#[sea_orm(table_name = "user", rename_all = "camelCase")]
pub struct Model {
#[sea_orm(primary_key)]
id: i32,
first_name: String, // firstName
#[sea_orm(column_name = "lAsTnAmE")]
last_name: String, // lAsTnAmE
}
#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "camelCase")]
pub enum TestEnum {
DefaultVariant, // defaultVariant
#[sea_orm(rename = "kebab-case")]
VariantKebabCase, // variant-kebab-case
#[sea_orm(rename = "snake_case")]
VariantSnakeCase, // variant_snake_case
#[sea_orm(string_value = "CuStOmStRiNgVaLuE")]
CustomStringValue, // CuStOmStRiNgVaLuE
}
// Remember to import `sea_orm_migration::schema::*`
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Users::Table)
.if_not_exists()
.col(pk_auto(Users::Id)) // Primary key with auto-increment
.col(uuid(Users::Pid)) // UUID column
.col(string_uniq(Users::Email)) // String column with unique constraint
.col(string(Users::Password)) // String column
.col(string(Users::ApiKey).unique_key())
.col(string(Users::Name))
.col(string_null(Users::ResetToken)) // Nullable string column
.col(timestamp_null(Users::ResetSentAt)) // Nullable timestamp column
.col(string_null(Users::EmailVerificationToken))
.col(timestamp_null(Users::EmailVerificationSentAt))
.col(timestamp_null(Users::EmailVerifiedAt))
.to_owned(),
)
.await
}
// ...
}
QuerySelect::tbl_col_asInsert::on_conflict_do_nothing https://github.com/SeaQL/sea-orm/pull/2244ActiveValue::set_if_not_equals() https://github.com/SeaQL/sea-orm/pull/2194ActiveValue::try_as_ref() https://github.com/SeaQL/sea-orm/pull/2197QuerySelect::order_by_with_nulls https://github.com/SeaQL/sea-orm/pull/2228get_xxx_connection_pool by default https://github.com/SeaQL/sea-orm/pull/2233QueryResult::column_names https://github.com/SeaQL/sea-orm/pull/2148@generated in generated code https://github.com/SeaQL/sea-orm/pull/2199DeriveActiveModel macro https://github.com/SeaQL/sea-orm/pull/1665migrate generate on empty mod.rs files https://github.com/SeaQL/sea-orm/pull/2064DerivePartialModel macro attribute entity now supports syn::Type https://github.com/SeaQL/sea-orm/pull/2137#[derive(DerivePartialModel)]
#[sea_orm(entity = "<entity::Model as ModelTrait>::Entity")]
struct EntityNameNotAIdent {
#[sea_orm(from_col = "foo2")]
_foo: i32,
#[sea_orm(from_col = "bar2")]
_bar: String,
}
RelationDef::from_alias() https://github.com/SeaQL/sea-orm/pull/2146let cf = Alias::new("cf");
assert_eq!(
cake::Entity::find()
.join_as(
JoinType::LeftJoin,
cake_filling::Relation::Cake.def().rev(),
cf.clone()
)
.join(
JoinType::LeftJoin,
cake_filling::Relation::Filling.def().from_alias(cf)
)
.build(DbBackend::MySql)
.to_string(),
[
"SELECT `cake`.`id`, `cake`.`name` FROM `cake`",
"LEFT JOIN `cake_filling` AS `cf` ON `cake`.`id` = `cf`.`cake_id`",
"LEFT JOIN `filling` ON `cf`.`filling_id` = `filling`.`id`",
]
.join(" ")
);
has_one relation for foreign key of unique index / constraint https://github.com/SeaQL/sea-orm/pull/2254ConnectOptions::pool_options() to ConnectOptions::sqlx_pool_options() https://github.com/SeaQL/sea-orm/pull/2145sqlx_common private, hiding sqlx_error_to_xxx_err https://github.com/SeaQL/sea-orm/pull/2145time to 0.3.36 https://github.com/SeaQL/sea-orm/pull/2267strum to 0.26 https://github.com/SeaQL/sea-orm/pull/2088sea-schema to 0.15.0sea-query-binder to 0.6.0sea-query to 0.31.0rocket_okapi example https://github.com/SeaQL/sea-orm/pull/2136Upgrade sea-query-binder to 0.6.0-rc.4 https://github.com/SeaQL/sea-orm/pull/2267
sea-query-binder to 0.6.0-rc.4 https://github.com/SeaQL/sea-orm/pull/2267time to 0.3.36 https://github.com/SeaQL/sea-orm/pull/2267Added non-TLS runtime https://github.com/SeaQL/sea-orm/pull/2256
QuerySelect::tbl_col_asInsert::on_conflict_do_nothing https://github.com/SeaQL/sea-orm/pull/2244has_one relation for foreign key of unique index / constraint https://github.com/SeaQL/sea-orm/pull/2254Introduce PrimaryKeyArity with ARITY constant https://github.com/SeaQL/sea-orm/pull/2185 `rust fn get_arity_of () -> usize { E::PrimaryKey::iter().cou
PrimaryKeyArity with ARITY constant https://github.com/SeaQL/sea-orm/pull/2185fn get_arity_of<E: EntityTrait>() -> usize {
E::PrimaryKey::iter().count() // before; runtime
<<E::PrimaryKey as PrimaryKeyTrait>::ValueType as PrimaryKeyArity>::ARITY // now; compile-time
}
ActiveModel to EntityTrait https://github.com/SeaQL/sea-orm/pull/2186rename_all attribute to DeriveEntityModel & DeriveActiveEnum https://github.com/SeaQL/sea-orm/pull/2170#[derive(DeriveEntityModel)]
#[sea_orm(table_name = "user", rename_all = "camelCase")]
pub struct Model {
#[sea_orm(primary_key)]
id: i32,
first_name: String, // firstName
#[sea_orm(column_name = "lAsTnAmE")]
last_name: String, // lAsTnAmE
}
#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "camelCase")]
pub enum TestEnum {
DefaultVariant, // defaultVariant
#[sea_orm(rename = "kebab-case")]
VariantKebabCase, // variant-kebab-case
#[sea_orm(rename = "snake_case")]
VariantSnakeCase, // variant_snake_case
#[sea_orm(string_value = "CuStOmStRiNgVaLuE")]
CustomStringValue, // CuStOmStRiNgVaLuE
}
ActiveValue::set_if_not_equals() https://github.com/SeaQL/sea-orm/pull/2194ActiveValue::try_as_ref() https://github.com/SeaQL/sea-orm/pull/2197QuerySelect::order_by_with_nulls https://github.com/SeaQL/sea-orm/pull/2228get_xxx_connection_pool by default https://github.com/SeaQL/sea-orm/pull/2233Added QueryResult::column_names https://github.com/SeaQL/sea-orm/pull/2148
QueryResult::column_names https://github.com/SeaQL/sea-orm/pull/2148@generated in generated code https://github.com/SeaQL/sea-orm/pull/2199sea-query to 0.31.0-rc.6sea-schema to 0.15.0-rc.6[sea-orm-macro] Qualify traits in DeriveActiveModel macro https://github.com/SeaQL/sea-orm/pull/1665
DeriveActiveModel macro https://github.com/SeaQL/sea-orm/pull/1665Renamed ConnectOptions::pool_options() to ConnectOptions::sqlx_pool_options() https://github.com/SeaQL/sea-orm/pull/2145
ConnectOptions::pool_options() to ConnectOptions::sqlx_pool_options() https://github.com/SeaQL/sea-orm/pull/2145sqlx_common private, hiding sqlx_error_to_xxx_err https://github.com/SeaQL/sea-orm/pull/2145migrate generate on empty mod.rs files https://github.com/SeaQL/sea-orm/pull/2064DerivePartialModel macro attribute entity now supports syn::Type https://github.com/SeaQL/sea-orm/pull/2137#[derive(DerivePartialModel)]
#[sea_orm(entity = "<entity::Model as ModelTrait>::Entity")]
struct EntityNameNotAIdent {
#[sea_orm(from_col = "foo2")]
_foo: i32,
#[sea_orm(from_col = "bar2")]
_bar: String,
}
RelationDef::from_alias() https://github.com/SeaQL/sea-orm/pull/2146let cf = Alias::new("cf");
assert_eq!(
cake::Entity::find()
.join_as(
JoinType::LeftJoin,
cake_filling::Relation::Cake.def().rev(),
cf.clone()
)
.join(
JoinType::LeftJoin,
cake_filling::Relation::Filling.def().from_alias(cf)
)
.build(DbBackend::MySql)
.to_string(),
[
"SELECT `cake`.`id`, `cake`.`name` FROM `cake`",
"LEFT JOIN `cake_filling` AS `cf` ON `cake`.`id` = `cf`.`cake_id`",
"LEFT JOIN `filling` ON `cf`.`filling_id` = `filling`.`id`",
]
.join(" ")
);
sea-schema to 0.15.0-rc.3strum to 0.26 https://github.com/SeaQL/sea-orm/pull/2088rocket_okapi example https://github.com/SeaQL/sea-orm/pull/2136[sea-orm-migration] schema helper https://github.com/SeaQL/sea-orm/pull/2099 ``rust // Remember to import sea_orm_migration::* use sea_orm_migration::
// Remember to import `sea_orm_migration::schema::*`
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Users::Table)
.if_not_exists()
.col(pk_auto(Users::Id)) // Primary key with auto-increment
.col(uuid(Users::Pid)) // UUID column
.col(string_uniq(Users::Email)) // String column with unique constraint
.col(string(Users::Password)) // String column
.col(string(Users::ApiKey).unique_key())
.col(string(Users::Name))
.col(string_null(Users::ResetToken)) // Nullable string column
.col(timestamp_null(Users::ResetSentAt)) // Nullable timestamp column
.col(string_null(Users::EmailVerificationToken))
.col(timestamp_null(Users::EmailVerificationSentAt))
.col(timestamp_null(Users::EmailVerifiedAt))
.to_owned(),
)
.await
}
// ...
}
sea-query to 0.31Nothing published for this version
Added feature flag sqlite-use-returning-for-3_35 to use SQLite's returning https://github.com/SeaQL/sea-orm/pull/2070
sqlite-use-returning-for-3_35 to use SQLite's returning https://github.com/SeaQL/sea-orm/pull/2070[sea-orm-cli] Fix entity generation for non-alphanumeric enum variants https://github.com/SeaQL/sea-orm/pull/1821
ConnectOptions::test_before_acquireAdded desc to Cursor paginator https://github.com/SeaQL/sea-orm/pull/2037
desc to Cursor paginator https://github.com/SeaQL/sea-orm/pull/2037Paginator's COUNT query https://github.com/SeaQL/sea-orm/pull/2030ConnectOptions https://github.com/SeaQL/sea-orm/pull/2055QuerySelect::lock_with_behavior https://github.com/SeaQL/sea-orm/pull/1867DeriveValueType macro https://github.com/SeaQL/sea-orm/pull/2054[sea-orm-macro] Comment attribute for Entity (#[sea_orm(comment = "action")]); create_table_from_entity supports comment https://github.com/SeaQL/sea-
#[sea_orm(comment = "action")]); create_table_from_entity supports comment https://github.com/SeaQL/sea-orm/pull/2009proxy) to database backend https://github.com/SeaQL/sea-orm/pull/1881, https://github.com/SeaQL/sea-orm/pull/2000is_in and is_not_in https://github.com/SeaQL/sea-orm/pull/2002sea-query to 0.30.5 https://github.com/SeaQL/sea-query/releases/tag/0.30.5Added #[sea_orm(skip)] for FromQueryResult derive macro https://github.com/SeaQL/sea-orm/pull/1954
#[sea_orm(skip)] for FromQueryResult derive macro https://github.com/SeaQL/sea-orm/pull/1954[sea-orm-cli] Fix duplicated active enum use statements on generated entities https://github.com/SeaQL/sea-orm/pull/1953
--enum-extra-derives https://github.com/SeaQL/sea-orm/pull/1934--enum-extra-attributes https://github.com/SeaQL/sea-orm/pull/1952Add support for root JSON arrays https://github.com/SeaQL/sea-orm/pull/1898 Now the following works (requires the json-array / postgres-array feature)
json-array / postgres-array feature)!#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "json_struct_vec")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "Json")]
pub struct_vec: Vec<JsonColumn>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, FromJsonQueryResult)]
pub struct JsonColumn {
pub value: String,
}
ValueTuple as hash key https://github.com/SeaQL/sea-orm/pull/1868sea-query to 0.30.2 https://github.com/SeaQL/sea-query/releases/tag/0.30.2[sea-orm-migration] Check if an index exists https://github.com/SeaQL/sea-orm/pull/1828
cursor_by to SelectTwo https://github.com/SeaQL/sea-orm/pull/1826DeriveValueType by qualifying QueryResult https://github.com/SeaQL/sea-orm/pull/1855Loader panic on empty inputssalvo to 0.50chrono to 0.4.30 https://github.com/SeaQL/sea-orm/pull/1858sea-query to 0.30.1sea-schema to 0.14.1find_xxx_related/linked https://github.com/SeaQL/sea-orm/pull/1811Added support for Postgres arrays in FromQueryResult impl of JsonValue https://github.com/SeaQL/sea-orm/pull/1598
FromQueryResult impl of JsonValue https://github.com/SeaQL/sea-orm/pull/1598find_with_related consolidation logic https://github.com/SeaQL/sea-orm/issues/1800Added MigratorTrait::migration_table_name() method to configure the name of migration table https://github.com/SeaQL/sea-orm/pull/1511 ```rust
0.12.0-rc.1: Yanked0.12.0-rc.2: 2023-05-190.12.0-rc.3: 2023-06-220.12.0-rc.4: 2023-07-080.12.0-rc.5: 2023-07-22MigratorTrait::migration_table_name() method to configure the name of migration table https://github.com/SeaQL/sea-orm/pull/1511#[async_trait::async_trait]
impl MigratorTrait for Migrator {
// Override the name of migration table
fn migration_table_name() -> sea_orm::DynIden {
Alias::new("override_migration_table_name").into_iden()
}
...
}
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
// By default, it's
// `JOIN `fruit` ON `cake`.`id` = `fruit`.`cake_id` AND `fruit`.`name` LIKE '%tropical%'`
#[sea_orm(
has_many = "super::fruit::Entity",
on_condition = r#"super::fruit::Column::Name.like("%tropical%")"#
)]
TropicalFruit,
// Or specify `condition_type = "any"` to override it,
// `JOIN `fruit` ON `cake`.`id` = `fruit`.`cake_id` OR `fruit`.`name` LIKE '%tropical%'`
#[sea_orm(
has_many = "super::fruit::Entity",
on_condition = r#"super::fruit::Column::Name.like("%tropical%")"#
condition_type = "any",
)]
OrTropicalFruit,
}
Identity supports tuple of DynIden with arity up to 12#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "primary_key_of_12")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id_1: String,
...
#[sea_orm(primary_key, auto_increment = false)]
pub id_12: bool,
}
DerivePartialModel https://github.com/SeaQL/sea-orm/pull/1597#[derive(DerivePartialModel, FromQueryResult)]
#[sea_orm(entity = "Cake")]
struct PartialCake {
name: String,
#[sea_orm(
from_expr = r#"SimpleExpr::FunctionCall(Func::upper(Expr::col((Cake, cake::Column::Name))))"#
)]
name_upper: String,
}
assert_eq!(
cake::Entity::find()
.into_partial_model::<PartialCake>()
.into_statement(DbBackend::Sqlite)
.to_string(),
r#"SELECT "cake"."name", UPPER("cake"."name") AS "name_upper" FROM "cake""#
);
DbErr::sql_err() method to convert error into common database errors SqlErr, such as unique constraint or foreign key violation errors. https://github.com/SeaQL/sea-orm/pull/1707assert!(matches!(
cake.into_active_model().insert(db).await
.expect_err("Insert a row with duplicated primary key")
.sql_err(),
Some(SqlErr::UniqueConstraintViolation(_))
));
assert!(matches!(
fk_cake.insert(db).await
.expect_err("Insert a row with invalid foreign key")
.sql_err(),
Some(SqlErr::ForeignKeyConstraintViolation(_))
));
Select::find_with_linked, similar to find_with_related: https://github.com/SeaQL/sea-orm/pull/1728, https://github.com/SeaQL/sea-orm/pull/1743fn find_with_related<R>(self, r: R) -> SelectTwoMany<E, R>
where R: EntityTrait, E: Related<R>;
fn find_with_linked<L, T>(self, l: L) -> SelectTwoMany<E, T>
where L: Linked<FromEntity = E, ToEntity = T>, T: EntityTrait;
// boths yields `Vec<(E::Model, Vec<F::Model>)>`
DeriveValueType derive macro for custom wrapper types, implementations of the required traits will be provided, you can customize the column_type and array_type if needed https://github.com/SeaQL/sea-orm/pull/1720#[derive(DeriveValueType)]
#[sea_orm(array_type = "Int")]
pub struct Integer(i32);
#[derive(DeriveValueType)]
#[sea_orm(column_type = "Boolean", array_type = "Bool")]
pub struct Boolbean(pub String);
#[derive(DeriveValueType)]
pub struct StringVec(pub Vec<String>);
DeriveDisplay derive macro to implements std::fmt::Display for enum https://github.com/SeaQL/sea-orm/pull/1726#[derive(DeriveDisplay)]
enum DisplayTea {
EverydayTea,
#[sea_orm(display_value = "Breakfast Tea")]
BreakfastTea,
}
assert_eq!(format!("{}", DisplayTea::EverydayTea), "EverydayTea");
assert_eq!(format!("{}", DisplayTea::BreakfastTea), "Breakfast Tea");
UpdateMany::exec_with_returning() https://github.com/SeaQL/sea-orm/pull/1677let models: Vec<Model> = Entity::update_many()
.col_expr(Column::Values, Expr::expr(..))
.exec_with_returning(db)
.await?;
default_expr in DeriveEntityModel https://github.com/SeaQL/sea-orm/pull/1474#[derive(DeriveEntityModel)]
#[sea_orm(table_name = "hello")]
pub struct Model {
#[sea_orm(default_expr = "Expr::current_timestamp()")]
pub timestamp: DateTimeUtc,
}
assert_eq!(
Column::Timestamp.def(),
ColumnType::TimestampWithTimeZone.def()
.default(Expr::current_timestamp())
);
ConnAcquireErr https://github.com/SeaQL/sea-orm/pull/1737enum DbErr {
ConnectionAcquire(ConnAcquireErr),
..
}
enum ConnAcquireErr {
Timeout,
ConnectionClosed,
}
Added Seaography integration https://github.com/SeaQL/sea-orm/pull/1599
Added DeriveEntityRelated macro which will implement seaography::RelationBuilder for RelatedEntity enumeration when the seaography feature is enabled
Added generation of seaography related information to sea-orm-codegen.
The RelatedEntity enum is added in entities files by sea-orm-cli when flag seaography is set:
/// SeaORM Entity
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::bakery::Entity")]
Bakery,
#[sea_orm(entity = "super::cake_baker::Entity")]
CakeBaker,
#[sea_orm(entity = "super::cake::Entity")]
Cake,
}
seaography_exampleOption<T> model field. A None value will be filled when the select result does not contain the Option<T> field without throwing an error. https://github.com/SeaQL/sea-orm/pull/1513migrate init command will create a .gitignore file when the migration folder reside in a Git repository https://github.com/SeaQL/sea-orm/pull/1334sea-orm-cli migrate generate "create accounts table" command will create m20230503_000000_create_accounts_table.rs for you https://github.com/SeaQL/sea-orm/pull/1570Migration::name() and Migration::status() getters for the name and status of sea_orm_migration::Migration https://github.com/SeaQL/sea-orm/pull/1519let migrations = Migrator::get_pending_migrations(db).await?;
assert_eq!(migrations.len(), 5);
let migration = migrations.get(0).unwrap();
assert_eq!(migration.name(), "m20220118_000002_create_fruit_table");
assert_eq!(migration.status(), MigrationStatus::Pending);
postgres-array feature will be enabled when sqlx-postgres backend is selected https://github.com/SeaQL/sea-orm/pull/1565String parameters in API with Into<String> https://github.com/SeaQL/sea-orm/pull/1439
IntoMockRow for any BTreeMap that is indexed by string impl IntoMockRow for BTreeMap<T, Value> where T: Into<String>ConnectOptions - impl From<T> for ConnectOptions where T: Into<String>ConnectOptions::new(T) where T: Into<String> to takes any string SQLStatement::from_string(DbBackend, T) where T: Into<String> to takes any string SQLStatement::from_sql_and_values(DbBackend, T, I) where I: IntoIterator<Item = Value>, T: Into<String> to takes any string SQLTransaction::from_sql_and_values(DbBackend, T, I) where I: IntoIterator<Item = Value>, T: Into<String> to takes any string SQLConnectOptions::set_schema_search_path(T) where T: Into<String> to takes any stringColumnTrait::like(), ColumnTrait::not_like(), ColumnTrait::starts_with(), ColumnTrait::ends_with() and ColumnTrait::contains() to takes any stringsea_query::{DynIden, RcOrArc, SeaRc} to entity prelude https://github.com/SeaQL/sea-orm/pull/1661expr, exprs and expr_as methods to QuerySelect trait https://github.com/SeaQL/sea-orm/pull/1702DatabaseConnection::ping https://github.com/SeaQL/sea-orm/pull/1627|db: DatabaseConnection| {
assert!(db.ping().await.is_ok());
db.clone().close().await;
assert!(matches!(db.ping().await, Err(DbErr::ConnectionAcquire)));
}
TryInsert that does not panic on empty inserts https://github.com/SeaQL/sea-orm/pull/1708// now, you can do:
let res = Bakery::insert_many(std::iter::empty())
.on_empty_do_nothing()
.exec(db)
.await;
assert!(matches!(res, Ok(TryInsertResult::Empty)));
let on = OnConflict::column(Column::Id).do_nothing().to_owned();
// Existing behaviour
let res = Entity::insert_many([..]).on_conflict(on).exec(db).await;
assert!(matches!(res, Err(DbErr::RecordNotInserted)));
// New API; now you can:
let res =
Entity::insert_many([..]).on_conflict(on).do_nothing().exec(db).await;
assert!(matches!(res, Ok(TryInsertResult::Conflicted)));
DeriveActiveEnum throwing errors because string_value consists non-UAX#31 compliant characters https://github.com/SeaQL/sea-orm/pull/1374#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(None)")]
pub enum StringValue {
#[sea_orm(string_value = "")]
Member1,
#[sea_orm(string_value = "$$")]
Member2,
}
// will now produce the following enum:
pub enum StringValueVariant {
__Empty,
_0x240x24,
}
Related<R> with via and to methods will not be generated if there exists multiple paths via an intermediate table https://github.com/SeaQL/sea-orm/pull/1435ActiveEnum::db_type() return type does not implement ColumnTypeTrait https://github.com/SeaQL/sea-orm/pull/1576insert_many failing if the models iterator is empty https://github.com/SeaQL/sea-orm/issues/873Option<T> model field. A None value will be filled when the select result does not contain the Option<T> field instead of throwing an error. https://github.com/SeaQL/sea-orm/pull/1513sea-strum dependency with upstream strum in sea-orm https://github.com/SeaQL/sea-orm/pull/1535
derive and strum features to sea-orm-macrosEnumIter is now shipped by sea-orm-macrosMany to Identity https://github.com/SeaQL/sea-orm/pull/1508hashable-value feature in SeaQuery, thus Value::Float(NaN) == Value::Float(NaN) would be true https://github.com/SeaQL/sea-orm/pull/1728, https://github.com/SeaQL/sea-orm/pull/1743DeriveActiveEnum derive macro no longer implement std::fmt::Display. You can use the new DeriveDisplay macro https://github.com/SeaQL/sea-orm/pull/1726sea-query/derive is no longer enabled by sea-orm, as such, Iden no longer works as a derive macro (it's still a trait). Instead, we are shipping a new macro DeriveIden https://github.com/SeaQL/sea-orm/pull/1740 https://github.com/SeaQL/sea-orm/pull/1755// then:
#[derive(Iden)]
#[iden = "category"]
pub struct CategoryEnum;
#[derive(Iden)]
pub enum Tea {
Table,
#[iden = "EverydayTea"]
EverydayTea,
}
// now:
#[derive(DeriveIden)]
#[sea_orm(iden = "category")]
pub struct CategoryEnum;
#[derive(DeriveIden)]
pub enum Tea {
Table,
#[sea_orm(iden = "EverydayTea")]
EverydayTea,
}
DbErr::ConnectionAcquire changed to ConnectionAcquire(ConnAcquireErr) https://github.com/SeaQL/sea-orm/pull/1737FromJsonQueryResult removed from entity preludesqlx to 0.7 https://github.com/SeaQL/sea-orm/pull/1742sea-query to 0.30 https://github.com/SeaQL/sea-orm/pull/1742sea-schema to 0.14 https://github.com/SeaQL/sea-orm/pull/1742syn to 2 https://github.com/SeaQL/sea-orm/pull/1713heck to 0.4 https://github.com/SeaQL/sea-orm/pull/1520, https://github.com/SeaQL/sea-orm/pull/1544strum to 0.25 https://github.com/SeaQL/sea-orm/pull/1752clap to 4.3 https://github.com/SeaQL/sea-orm/pull/1468ouroboros to 0.17 https://github.com/SeaQL/sea-orm/pull/1724bae with sea-bae https://github.com/SeaQL/sea-orm/pull/1739Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.11.1...0.12.1
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Re-export sea_orm::ConnectionTrait in sea_orm_migration::prelude https://github.com/SeaQL/sea-orm/pull/1577
sea_orm::ConnectionTrait in sea_orm_migration::prelude https://github.com/SeaQL/sea-orm/pull/1577FromQueryResult derive macro https://github.com/SeaQL/sea-orm/pull/1464, https://github.com/SeaQL/sea-orm/pull/1603#[derive(FromQueryResult)]
struct GenericTest<T: TryGetable> {
foo: i32,
bar: T,
}
trait MyTrait {
type Item: TryGetable;
}
#[derive(FromQueryResult)]
struct TraitAssociateTypeTest<T>
where
T: MyTrait,
{
foo: T::Item,
}
tracing-subscriber dependency to 0.3.17 https://github.com/SeaQL/sea-orm/pull/1609Enable required syn features https://github.com/SeaQL/sea-orm/pull/1556
syn features https://github.com/SeaQL/sea-orm/pull/1556sea_query::BlobSize in sea_orm::entity::prelude https://github.com/SeaQL/sea-orm/pull/1548Fixes DeriveActiveEnum (by qualifying ColumnTypeTrait::def) https://github.com/SeaQL/sea-orm/issues/1478
DeriveActiveEnum (by qualifying ColumnTypeTrait::def) https://github.com/SeaQL/sea-orm/issues/1478sea-orm-cli generate entity -u '<DB-URL>' will now generate the following code for each Binary or VarBinary columns in compact format https://github.com/SeaQL/sea-orm/pull/1529#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "binary")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub binary: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Blob(Some(10)))")]
pub binary_10: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Tiny)")]
pub binary_tiny: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Medium)")]
pub binary_medium: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Long)")]
pub binary_long: Vec<u8>,
#[sea_orm(column_type = "VarBinary(10)")]
pub var_binary: Vec<u8>,
}
sea-orm-cli generate entity -u '<DB-URL>' --expanded-format will now generate the following code for each Binary or VarBinary columns in expanded format https://github.com/SeaQL/sea-orm/pull/1529impl ColumnTrait for Column {
type EntityName = Entity;
fn def(&self) -> ColumnDef {
match self {
Self::Id => ColumnType::Integer.def(),
Self::Binary => ColumnType::Binary(sea_orm::sea_query::BlobSize::Blob(None)).def(),
Self::Binary10 => {
ColumnType::Binary(sea_orm::sea_query::BlobSize::Blob(Some(10u32))).def()
}
Self::BinaryTiny => ColumnType::Binary(sea_orm::sea_query::BlobSize::Tiny).def(),
Self::BinaryMedium => ColumnType::Binary(sea_orm::sea_query::BlobSize::Medium).def(),
Self::BinaryLong => ColumnType::Binary(sea_orm::sea_query::BlobSize::Long).def(),
Self::VarBinary => ColumnType::VarBinary(10u32).def(),
}
}
}
Simple data loader https://github.com/SeaQL/sea-orm/pull/1238, https://github.com/SeaQL/sea-orm/pull/1443
0.11.0-rc.10.11.0-rc.2uuid::fmt module https://github.com/SeaQL/sea-orm/pull/1325ActiveEnum field as primary key https://github.com/SeaQL/sea-orm/pull/1414ActiveModelBehavior receive db connection as a parameter https://github.com/SeaQL/sea-orm/pull/1145, https://github.com/SeaQL/sea-orm/pull/1328execute_unprepared method to DatabaseConnection and DatabaseTransaction https://github.com/SeaQL/sea-orm/pull/1327Select::into_tuple to select rows as tuples (instead of defining a custom Model) https://github.com/SeaQL/sea-orm/pull/1311#[serde(skip_deserializing)] for primary key columns https://github.com/SeaQL/sea-orm/pull/846, https://github.com/SeaQL/sea-orm/pull/1186, https://github.com/SeaQL/sea-orm/pull/1318#[serde(skip)] for hidden columns https://github.com/SeaQL/sea-orm/pull/1171, https://github.com/SeaQL/sea-orm/pull/1320#[sea_orm(column_type = "JsonBinary")] macro attribute https://github.com/SeaQL/sea-orm/pull/1346MockDatabase::append_exec_results(), MockDatabase::append_query_results(), MockDatabase::append_exec_errors() and MockDatabase::append_query_errors() take any types implemented IntoIterator trait https://github.com/SeaQL/sea-orm/pull/1367find_by_id and delete_by_id take any Into primary key value https://github.com/SeaQL/sea-orm/pull/1362QuerySelect::offset and QuerySelect::limit takes in Into<Option<u64>> where None would reset them https://github.com/SeaQL/sea-orm/pull/1410DatabaseConnection::close https://github.com/SeaQL/sea-orm/pull/1236is_null getter for ColumnDef https://github.com/SeaQL/sea-orm/pull/1381ActiveValue::reset to convert Unchanged into Set https://github.com/SeaQL/sea-orm/pull/1177QueryTrait::apply_if to optionally apply a filter https://github.com/SeaQL/sea-orm/pull/1415sea-orm-internal feature flag to expose some SQLx types
DatabaseConnection::get_*_connection_pool() for accessing the inner SQLx connection pool https://github.com/SeaQL/sea-orm/pull/1297axum to 0.6.1 https://github.com/SeaQL/sea-orm/pull/1285sea-query to 0.28 https://github.com/SeaQL/sea-orm/pull/1366sea-query-binder to 0.3 https://github.com/SeaQL/sea-orm/pull/1366sea-schema to 0.11 https://github.com/SeaQL/sea-orm/pull/13661.67.0 https://github.com/SeaQL/sea-orm/pull/1426vec! macro https://github.com/SeaQL/sea-orm/pull/1367DeriveColumn (by qualifying IdenStatic::as_str) https://github.com/SeaQL/sea-orm/pull/1280RecordNotInserted error if non of them are being inserted https://github.com/SeaQL/sea-orm/pull/1021
insert_many with on_conflict and do_nothing panics if no rows are inserted on Postgres https://github.com/SeaQL/sea-orm/issues/899last_insert_id if not needed https://github.com/SeaQL/sea-orm/pull/1403
RecordNotInserted and RecordNotUpdated to DbErrConnectionTrait::execute_unprepared method https://github.com/SeaQL/sea-orm/pull/1327TryGetable changed:// then
fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError>;
// now; ColIdx can be `&str` or `usize`
fn try_get_by<I: ColIdx>(res: &QueryResult, index: I) -> Result<Self, TryGetError>;
So if you implemented it yourself:
impl TryGetable for XXX {
- fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> {
+ fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, idx: I) -> Result<Self, TryGetError> {
- let value: YYY = res.try_get(pre, col).map_err(TryGetError::DbErr)?;
+ let value: YYY = res.try_get_by(idx).map_err(TryGetError::DbErr)?;
..
}
}
ActiveModelBehavior trait becomes async trait https://github.com/SeaQL/sea-orm/pull/1328.
If you overridden the default ActiveModelBehavior implementation:#[async_trait::async_trait]
impl ActiveModelBehavior for ActiveModel {
async fn before_save<C>(self, db: &C, insert: bool) -> Result<Self, DbErr>
where
C: ConnectionTrait,
{
// ...
}
// ...
}
DbErr::RecordNotFound("None of the database rows are affected") is moved to a dedicated error variant DbErr::RecordNotUpdated https://github.com/SeaQL/sea-orm/pull/1425let res = Update::one(cake::ActiveModel {
name: Set("Cheese Cake".to_owned()),
..model.into_active_model()
})
.exec(&db)
.await;
// then
assert_eq!(
res,
Err(DbErr::RecordNotFound(
"None of the database rows are affected".to_owned()
))
);
// now
assert_eq!(res, Err(DbErr::RecordNotUpdated));
sea_orm::ColumnType was replaced by sea_query::ColumnType https://github.com/SeaQL/sea-orm/pull/1395
ColumnType::def was moved to ColumnTypeTraitColumnType::Binary becomes a tuple variant which takes in additional option sea_query::BlobSizeColumnType::Custom takes a sea_query::DynIden instead of String and thus a new method custom is added (note the lowercase)// Compact Entity
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "fruit")]
pub struct Model {
- #[sea_orm(column_type = r#"Custom("citext".to_owned())"#)]
+ #[sea_orm(column_type = r#"custom("citext")"#)]
pub column: String,
}
// Expanded Entity
impl ColumnTrait for Column {
type EntityName = Entity;
fn def(&self) -> ColumnDef {
match self {
- Self::Column => ColumnType::Custom("citext".to_owned()).def(),
+ Self::Column => ColumnType::custom("citext").def(),
}
}
}
axum example should use tokio runtime https://github.com/SeaQL/sea-orm/pull/1428Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.10.0...0.11.0
Nothing published for this version
Nothing published for this version
Inserting active models by insert_many with on_conflict and do_nothing panics if no rows are inserted on Postgres https://github.com/SeaQL/sea-orm/iss
insert_many with on_conflict and do_nothing panics if no rows are inserted on Postgres https://github.com/SeaQL/sea-orm/issues/899Cast enum values when constructing update many query https://github.com/SeaQL/sea-orm/pull/1178
DeriveColumn (by qualifying IdenStatic::as_str) https://github.com/SeaQL/sea-orm/pull/1280Add QuerySelect::columns method - select multiple columns https://github.com/SeaQL/sea-orm/pull/1264
QuerySelect::columns method - select multiple columns https://github.com/SeaQL/sea-orm/pull/1264DeriveEntityModel derive macro: when parsing field type, always treat field with Option<T> as nullable column https://github.com/SeaQL/sea-orm/pull/1257Related implementation for many-to-many relation with extra columns https://github.com/SeaQL/sea-orm/pull/1260TryGetableFromJson::try_get_from_json() - deserializing into Self directly without the need of a intermediate serde_json::Value https://github.com/SeaQL/sea-orm/pull/1249Fix DeriveActiveEnum expand enum variant starts with number https://github.com/SeaQL/sea-orm/pull/1219
DbErr to MockDatabase https://github.com/SeaQL/sea-orm/pull/1241IS IN enum values expression https://github.com/SeaQL/sea-orm/pull/1183[sea-orm-cli] Set search path when initializing Postgres connection for CLI generate entity https://github.com/SeaQL/sea-orm/pull/1212
_ prefix to enum variant starts with number https://github.com/SeaQL/sea-orm/pull/1211Insert::exec_without_returning https://github.com/SeaQL/sea-orm/pull/1208[sea-orm-rocket] added sqlx_logging to Config https://github.com/SeaQL/sea-orm/pull/1192
sqlx_logging to Config https://github.com/SeaQL/sea-orm/pull/1192query_one/all https://github.com/SeaQL/sea-orm/pull/1165StreamTrait lifetime https://github.com/SeaQL/sea-orm/pull/1161UpdateGetPrimaryKey https://github.com/SeaQL/sea-orm/pull/1180[sea-orm-cli] Escape module name defined with Rust keywords https://github.com/SeaQL/sea-orm/pull/1052
- in it https://github.com/SeaQL/sea-orm/pull/879, https://github.com/SeaQL/sea-orm/pull/1155time crate for SQLite https://github.com/SeaQL/sea-orm/pull/995Related for m-to-n relation https://github.com/SeaQL/sea-orm/pull/1075-u when executing migrate generate command https://github.com/SeaQL/sea-orm/pull/1157sea_orm:: inside DeriveActiveEnum derive macros https://github.com/SeaQL/sea-orm/pull/1146, https://github.com/SeaQL/sea-orm/pull/1154Vec<f32> or Vec<f64> should not derive Eq on the model struct https://github.com/SeaQL/sea-orm/pull/1158cli feature to optionally include dependencies that are required by the CLI https://github.com/SeaQL/sea-orm/pull/978sea-schema to 0.10.2 https://github.com/SeaQL/sea-orm/pull/1153Better error types (carrying SQLx Error) https://github.com/SeaQL/sea-orm/pull/1002
DeriveRelation on empty Relation enum https://github.com/SeaQL/sea-orm/pull/1019Eq if possible https://github.com/SeaQL/sea-orm/pull/988distinct & distinct_on expression https://github.com/SeaQL/sea-orm/pull/902fn column() also handle enum type https://github.com/SeaQL/sea-orm/pull/973acquire_timeout on ConnectOptions https://github.com/SeaQL/sea-orm/pull/897migrate fresh command will drop all PostgreSQL types https://github.com/SeaQL/sea-orm/pull/864, https://github.com/SeaQL/sea-orm/pull/991IntoActiveValue for Option values https://github.com/SeaQL/sea-orm/pull/833into_model & into_json to Cursor https://github.com/SeaQL/sea-orm/pull/1112set_schema_search_path method to ConnectOptions for setting schema search path of PostgreSQL connection https://github.com/SeaQL/sea-orm/pull/1056time types as serde_json::Value https://github.com/SeaQL/sea-orm/pull/1042fmt::Display for ActiveEnum https://github.com/SeaQL/sea-orm/pull/986TryFrom<ActiveModel> for Model https://github.com/SeaQL/sea-orm/pull/990usize with u64 in PaginatorTrait https://github.com/SeaQL/sea-orm/pull/789DbErr changed as a result of https://github.com/SeaQL/sea-orm/pull/1002ColumnType::Enum structure changed:enum ColumnType {
// then
Enum(String, Vec<String>)
// now
Enum {
/// Name of enum
name: DynIden,
/// Variants of enum
variants: Vec<DynIden>,
}
...
}
// example
#[derive(Iden)]
enum TeaEnum {
#[iden = "tea"]
Enum,
#[iden = "EverydayTea"]
EverydayTea,
#[iden = "BreakfastTea"]
BreakfastTea,
}
// then
ColumnDef::new(active_enum_child::Column::Tea)
.enumeration("tea", vec!["EverydayTea", "BreakfastTea"])
// now
ColumnDef::new(active_enum_child::Column::Tea)
.enumeration(TeaEnum::Enum, [TeaEnum::EverydayTea, TeaEnum::BreakfastTea])
array_type was added to ValueType:impl sea_orm::sea_query::ValueType for MyType {
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::TypeName
}
...
}
ActiveEnum::name() changed return type to DynIden:#[derive(Debug, Iden)]
#[iden = "category"]
pub struct CategoryEnum;
impl ActiveEnum for Category {
// then
fn name() -> String {
"category".to_owned()
}
// now
fn name() -> DynIden {
SeaRc::new(CategoryEnum)
}
...
}
dotenv with dotenvy in examples https://github.com/SeaQL/sea-orm/pull/1085rocket_okapi https://github.com/SeaQL/sea-orm/pull/1071sea-query to 0.26 https://github.com/SeaQL/sea-orm/pull/985Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.9.0...0.10.0
fn column() also handle enum type https://github.com/SeaQL/sea-orm/pull/973
fn column() also handle enum type https://github.com/SeaQL/sea-orm/pull/973DeriveRelation on empty Relation enum https://github.com/SeaQL/sea-orm/pull/1019IntoActiveValue for time types https://github.com/SeaQL/sea-orm/pull/1041FromJsonQueryResult derive macro https://github.com/SeaQL/sea-orm/pull/1081[sea-orm-cli] Migrator CLI handles init and generate commands https://github.com/SeaQL/sea-orm/pull/931
with-copy-enums flag to conditional derive Copy on ActiveEnum https://github.com/SeaQL/sea-orm/pull/936chrono default features https://github.com/SeaQL/sea-orm/pull/9501.60 https://github.com/SeaQL/sea-orm/pull/938sea-query to 0.26.3In this minor release, we removed time v0.1 from the dependency graph
[sea-orm-cli] Codegen support for VarBinary column type https://github.com/SeaQL/sea-orm/pull/746
VarBinary column type https://github.com/SeaQL/sea-orm/pull/746RelationDef & RelationBuilder should be Send & Sync https://github.com/SeaQL/sea-orm/pull/898async_trait https://github.com/SeaQL/sea-orm/pull/737Cursor pagination https://github.com/SeaQL/sea-orm/pull/822
DeriveMigrationName and sea_orm_migration::util::get_file_stem https://github.com/SeaQL/sea-orm/pull/736FromJsonQueryResult for deserializing Json from query result https://github.com/SeaQL/sea-orm/pull/794sqlx_logging_level to ConnectOptions https://github.com/SeaQL/sea-orm/pull/800num_items_and_pages to Paginator https://github.com/SeaQL/sea-orm/pull/768TryFromU64 for time https://github.com/SeaQL/sea-orm/pull/849Insert::on_conflict https://github.com/SeaQL/sea-orm/pull/791QuerySelect::join_as and QuerySelect::join_as_rev https://github.com/SeaQL/sea-orm/pull/852TryGetError::Null https://github.com/SeaQL/sea-orm/pull/853time crate https://github.com/SeaQL/sea-orm/pull/724clap to 3.2 https://github.com/SeaQL/sea-orm/pull/706time to 0.3 https://github.com/SeaQL/sea-orm/pull/834sqlx to 0.6 https://github.com/SeaQL/sea-orm/pull/834uuid to 1.0 https://github.com/SeaQL/sea-orm/pull/834sea-query to 0.26 https://github.com/SeaQL/sea-orm/pull/834sea-schema to 0.9 https://github.com/SeaQL/sea-orm/pull/834SelectTwoMany::one() has been dropped https://github.com/SeaQL/sea-orm/pull/813, you can get (Entity, Vec<RelatedEntity>) by first querying a single model from Entity, then use [ModelTrait::find_related] on the model.["sqlx-json", "sqlx-chrono", "sqlx-decimal", "sqlx-uuid", "sqlx-time"] are not needed and now removed. Instead, with-time will enable sqlx?/time only if sqlx is already enabled. As a consequence, now the features with-json, with-chrono, with-rust_decimal, with-uuid, with-time will not be enabled as a side-effect of enabling sqlx.Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.8.0...0.9.0
[sea-orm-cli] sea migrate generate to generate a new, empty migration file https://github.com/SeaQL/sea-orm/pull/656
sea migrate generate to generate a new, empty migration file https://github.com/SeaQL/sea-orm/pull/656max_connections option to CLI https://github.com/SeaQL/sea-orm/pull/670Eq, Clone for DbErr https://github.com/SeaQL/sea-orm/pull/677is_changed to ActiveModelTrait https://github.com/SeaQL/sea-orm/pull/683DerivePrimaryKey with custom primary key column name https://github.com/SeaQL/sea-orm/pull/694DeriveEntityModel macros override column name https://github.com/SeaQL/sea-orm/pull/695DEFAULT https://github.com/SeaQL/sea-orm/pull/589sea-orm-migration. sea_schema::migration::prelude should be replaced by sea_orm_migration::prelude in all migration filessea-query to 0.24.x, sea-schema to 0.8.xFull Changelog: https://github.com/SeaQL/sea-orm/compare/0.7.1...0.8.0
Update ActiveModel by JSON by @billy1624 in https://github.com/SeaQL/sea-orm/pull/492
time crate by @billy1624 https://github.com/SeaQL/sea-orm/pull/602delete_by_id @ShouvikGhosh2048 https://github.com/SeaQL/sea-orm/pull/590PaginatorTrait for SelectorRaw @shinbunbun https://github.com/SeaQL/sea-orm/pull/617Send bound to QueryStream and TransactionStream by @sebpuetz https://github.com/SeaQL/sea-orm/pull/471Send to StreamTrait by @nappa85 https://github.com/SeaQL/sea-orm/pull/622sea as an alternative bin name to sea-orm-cli by @ZhangHanDong https://github.com/SeaQL/sea-orm/pull/558mock from default features by @billy1624 https://github.com/SeaQL/sea-orm/pull/562create_table_from_entity will no longer create index for MySQL, please use the new method create_index_from_entityDatabaseConnection Clone with the default features enabled https://github.com/SeaQL/sea-orm/issues/438Clone by default https://github.com/SeaQL/sea-orm/issues/517.into_json() on queries https://github.com/SeaQL/sea-orm/issues/530#[sea_orm(indexed)] only works for MySQL https://github.com/SeaQL/sea-orm/issues/554sea-orm-cli generate --with-serde does not work on Postgresql custom type https://github.com/SeaQL/sea-orm/issues/581sea-orm-cli generate --expanded-format panic when postgres table contains enum type https://github.com/SeaQL/sea-orm/issues/614.into_json() on queries https://github.com/SeaQL/sea-orm/issues/619Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.6.0...0.7.0
Migration Support by @billy1624 in https://github.com/SeaQL/sea-orm/pull/335
DateTime<Utc> & DateTime<Local> by @billy1624 in https://github.com/SeaQL/sea-orm/pull/489max_lifetime connection option by @billy1624 in https://github.com/SeaQL/sea-orm/pull/493column_name proc_macro attribute by @billy1624 in https://github.com/SeaQL/sea-orm/pull/433r# prefix when deriving FromQueryResult by @smrtrfszm in https://github.com/SeaQL/sea-orm/pull/494DateTime<Utc> & DateTime<Local> https://github.com/SeaQL/sea-orm/issues/381column_name proc_macro attribute if column name isn't in snake case https://github.com/SeaQL/sea-orm/issues/395Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.5.0...0.6.0
Why insert, update, etc return an ActiveModel instead of Model? https://github.com/SeaQL/sea-orm/issues/289
ActiveValue https://github.com/SeaQL/sea-orm/issues/321Model by @billy1624 in https://github.com/SeaQL/sea-orm/pull/339ActiveValue by @billy1624 in https://github.com/SeaQL/sea-orm/pull/340ModelTrait::delete by @billy1624 in https://github.com/SeaQL/sea-orm/pull/396sea-strum lib back to strum by @billy1624 in https://github.com/SeaQL/sea-orm/pull/361ActiveModel::insert and ActiveModel::update return Model instead of ActiveModelActiveModelBehavior::after_save takes Model as input instead of ActiveModelsea_orm::unchanged_active_value_not_intended_for_public_use to sea_orm::UnchangedActiveValue::unset to ActiveValue::not_setActiveValue::is_unset to ActiveValue::is_not_setPartialEq of ActiveValue will also check the equality of state instead of just checking the equality of valueFull Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.2...0.5.0
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →