All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- [sea-orm-macros]
impl From<Model> for ActiveModel
instead ofimpl From<<Entity as sea_orm::EntityTrait>::Model> for ActiveModel
#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),
}
}
}
1.1.0-rc.1
: 2024-08-091.1.0-rc.2
: 2024-10-041.1.0-rc.3
: 2024-10-08
- [sea-orm-macros] Call
EnumIter::get
using fully qualified syntax #2321 - Construct
DatabaseConnection
directly fromsqlx::PgPool
,sqlx::SqlitePool
andsqlx::MySqlPool
#2348 - [sea-orm-migration] Add
pk_uuid
schema helper #2329 - [sea-orm-migration] Allow
custom
andcustom_null
schema helper to take column name and alias of differentIntoIden
types #2326 - Add
ColumnDef::get_column_default
getter #2387
- Upgrade
sqlx
to0.8.2
#2305, #2371 - Upgrade
bigdecimal
to0.4
#2305 - Upgrade
sea-query
to0.32.0-rc
#2305 - Upgrade
sea-query-binder
to0.7.0-rc
#2305 - Upgrade
sea-schema
to0.16.0-rc
#2305 - Upgrade
ouroboros
to0.18
#2353
- Added
ConnectOptions::connect_lazy
for creating DB connection pools without establishing connections up front #2268
- 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 feature guardproxy
, and we believe it shouldn't impact majority of users. #2278
- [sea-orm-codegen] Fix
ColumnType
to Rust type resolution #2313
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-25
- Introduce
PrimaryKeyArity
withARITY
constant #2185
fn get_arity_of<E: EntityTrait>() -> usize {
E::PrimaryKey::iter().count() // before; runtime
<<E::PrimaryKey as PrimaryKeyTrait>::ValueType as PrimaryKeyArity>::ARITY // now; compile-time
}
- Associate
ActiveModel
toEntityTrait
#2186 - [sea-orm-macros] Added
rename_all
attribute toDeriveEntityModel
&DeriveActiveEnum
#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
}
- [sea-orm-migration] schema helper #2099
// 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
}
// ...
}
- Added non-TLS runtime #2256
- Added
QuerySelect::tbl_col_as
- Added
Insert::on_conflict_do_nothing
#2244 - Migration schema nullable column set NULL explicitly #2255
- Added
ActiveValue::set_if_not_equals()
#2194 - Added
ActiveValue::try_as_ref()
#2197 - Added
QuerySelect::order_by_with_nulls
#2228 - Expose
get_xxx_connection_pool
by default #2233 - Added
QueryResult::column_names
#2148 - [sea-orm-macro] Add
@generated
in generated code #2199 - [sea-orm-macro] Qualify traits in
DeriveActiveModel
macro #1665 - [sea-orm-cli] Fix
migrate generate
on emptymod.rs
files #2064 DerivePartialModel
macro attributeentity
now supportssyn::Type
#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,
}
- Added
RelationDef::from_alias()
#2146
let 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(" ")
);
- Set schema search path in Postgres without enclosing single quote #2241
- [sea-orm-cli] Generate
has_one
relation for foreign key of unique index / constraint #2254
- Renamed
ConnectOptions::pool_options()
toConnectOptions::sqlx_pool_options()
#2145 - Made
sqlx_common
private, hidingsqlx_error_to_xxx_err
#2145 - Rework SQLite type mappings #2077, #2078
- Upgrade
time
to0.3.36
#2267 - Upgrade
strum
to0.26
#2088 - Upgrade
sea-schema
to0.15.0
- Upgrade
sea-query-binder
to0.6.0
- Upgrade
sea-query
to0.31.0
- Reduce warnings in integration tests #2177
- Improved Actix example to return 404 not found on unexpected inputs #2140
- Re-enable
rocket_okapi
example #2136
- Added non-TLS runtime #2256
- Added
QuerySelect::tbl_col_as
- Added
Insert::on_conflict_do_nothing
#2244 - Migration schema nullable column set NULL explicitly #2255
- Set schema search path in Postgres without enclosing single quote #2241
- [sea-orm-cli] Generate
has_one
relation for foreign key of unique index / constraint #2254
- Introduce
PrimaryKeyArity
withARITY
constant #2185
fn get_arity_of<E: EntityTrait>() -> usize {
E::PrimaryKey::iter().count() // before; runtime
<<E::PrimaryKey as PrimaryKeyTrait>::ValueType as PrimaryKeyArity>::ARITY // now; compile-time
}
- Associate
ActiveModel
toEntityTrait
#2186 - [sea-orm-macros] Added
rename_all
attribute toDeriveEntityModel
&DeriveActiveEnum
#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
}
- Added
ActiveValue::set_if_not_equals()
#2194 - Added
ActiveValue::try_as_ref()
#2197 - Added
QuerySelect::order_by_with_nulls
#2228 - Expose
get_xxx_connection_pool
by default #2233
- Upgrade
sea-query
to0.31.0-rc.6
- Upgrade
sea-schema
to0.15.0-rc.6
- Reduce warnings in integration tests #2177
- [sea-orm-macro] Qualify traits in
DeriveActiveModel
macro #1665
- Renamed
ConnectOptions::pool_options()
toConnectOptions::sqlx_pool_options()
#2145 - Made
sqlx_common
private, hidingsqlx_error_to_xxx_err
#2145
- [sea-orm-cli] Fix
migrate generate
on emptymod.rs
files #2064 DerivePartialModel
macro attributeentity
now supportssyn::Type
#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,
}
- Added
RelationDef::from_alias()
#2146
let 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(" ")
);
- Upgrade
sea-schema
to0.15.0-rc.3
- Upgrade
strum
to0.26
#2088
- Improved Actix example to return 404 not found on unexpected inputs #2140
- Re-enable
rocket_okapi
example #2136
- [sea-orm-migration] schema helper #2099
// 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
}
// ...
}
- Added feature flag
sqlite-use-returning-for-3_35
to use SQLite's returning #2070 - Added Loco example #2092
- [sea-orm-cli] Fix entity generation for non-alphanumeric enum variants #1821
- [sea-orm-cli] Fix entity generation for relations with composite keys #2071
- Added
ConnectOptions::test_before_acquire
- Added
desc
toCursor
paginator #2037
- Improve query performance of
Paginator
'sCOUNT
query #2030 - Added SQLx slow statements logging to
ConnectOptions
#2055 - Added
QuerySelect::lock_with_behavior
#1867
- [sea-orm-macro] Qualify types in
DeriveValueType
macro #2054
- Fix clippy warnings on 1.75 #2057
- [sea-orm-macro] Comment attribute for Entity (
#[sea_orm(comment = "action")]
);create_table_from_entity
supports comment #2009 - Added "proxy" (feature flag
proxy
) to database backend #1881, #2000
- Cast enums in
is_in
andis_not_in
#2002
- Updated
sea-query
to0.30.5
https://github.com/SeaQL/sea-query/releases/tag/0.30.5
- Add source annotations to errors #1999
- Updated
sea-query
to0.30.4
https://github.com/SeaQL/sea-query/releases/tag/0.30.4
- Implement
StatementBuilder
forsea_query::WithQuery
#1960
- Upgrade
axum
example to0.7
#1984
- Added method
expr_as_
that acceptsself
#1979
- Updated
sea-query
to0.30.3
https://github.com/SeaQL/sea-query/releases/tag/0.30.3
- Added
#[sea_orm(skip)]
forFromQueryResult
derive macro #1954
- [sea-orm-cli] Fix duplicated active enum use statements on generated entities #1953
- [sea-orm-cli] Added
--enum-extra-derives
#1934 - [sea-orm-cli] Added
--enum-extra-attributes
#1952
- Add support for root JSON arrays #1898
Now the following works (requires the
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,
}
- Loader: use
ValueTuple
as hash key #1868
- Updated
sea-query
to0.30.2
https://github.com/SeaQL/sea-query/releases/tag/0.30.2
- [sea-orm-cli] Support generation of related entity with composite foreign key #1693
- [sea-orm-macro] Fixed
DeriveValueType
by qualifyingQueryResult
#1855 - Fixed
Loader
panic on empty inputs
- Upgraded
salvo
to0.50
- Upgraded
chrono
to0.4.30
#1858 - Updated
sea-query
to0.30.1
- Updated
sea-schema
to0.14.1
- Added test cases for
find_xxx_related/linked
#1811
- Added support for Postgres arrays in
FromQueryResult
impl ofJsonValue
#1598
- Fixed
find_with_related
consolidation logic #1800
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-22
- Added
MigratorTrait::migration_table_name()
method to configure the name of migration table #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()
}
...
}
- Added option to construct chained AND / OR join on condition #1433
#[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,
}
- Supports entity with composite primary key of arity 12 #1508
Identity
supports tuple ofDynIden
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,
}
- Added macro
DerivePartialModel
#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""#
);
- Added
DbErr::sql_err()
method to convert error into common database errorsSqlErr
, such as unique constraint or foreign key violation errors. #1707
assert!(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(_))
));
fn 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>)>`
- Added
DeriveValueType
derive macro for custom wrapper types, implementations of the required traits will be provided, you can customize thecolumn_type
andarray_type
if needed #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>);
- Added
DeriveDisplay
derive macro to implementsstd::fmt::Display
for enum #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");
- Added
UpdateMany::exec_with_returning()
#1677
let models: Vec<Model> = Entity::update_many()
.col_expr(Column::Values, Expr::expr(..))
.exec_with_returning(db)
.await?;
- Supporting
default_expr
inDeriveEntityModel
#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())
);
- Introduced new
ConnAcquireErr
#1737
enum DbErr {
ConnectionAcquire(ConnAcquireErr),
..
}
enum ConnAcquireErr {
Timeout,
ConnectionClosed,
}
Added Seaography integration #1599
-
Added
DeriveEntityRelated
macro which will implementseaography::RelationBuilder
forRelatedEntity
enumeration when theseaography
feature is enabled -
Added generation of
seaography
related information tosea-orm-codegen
.The
RelatedEntity
enum is added in entities files bysea-orm-cli
when flagseaography
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,
}
- Added
seaography_example
- Supports for partial select of
Option<T>
model field. ANone
value will be filled when the select result does not contain theOption<T>
field without throwing an error. #1513 - [sea-orm-cli] the
migrate init
command will create a.gitignore
file when the migration folder reside in a Git repository #1334 - [sea-orm-cli] Added support for generating migration of space separated name, for example executing
sea-orm-cli migrate generate "create accounts table"
command will createm20230503_000000_create_accounts_table.rs
for you #1570 - Added
Migration::name()
andMigration::status()
getters for the name and status ofsea_orm_migration::Migration
#1519
let 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);
- The
postgres-array
feature will be enabled whensqlx-postgres
backend is selected #1565 - Replace
String
parameters in API withInto<String>
#1439- Implements
IntoMockRow
for anyBTreeMap
that is indexed by stringimpl IntoMockRow for BTreeMap<T, Value> where T: Into<String>
- Converts any string value into
ConnectOptions
-impl From<T> for ConnectOptions where T: Into<String>
- Changed the parameter of method
ConnectOptions::new(T) where T: Into<String>
to takes any string SQL - Changed the parameter of method
Statement::from_string(DbBackend, T) where T: Into<String>
to takes any string SQL - Changed the parameter of method
Statement::from_sql_and_values(DbBackend, T, I) where I: IntoIterator<Item = Value>, T: Into<String>
to takes any string SQL - Changed the parameter of method
Transaction::from_sql_and_values(DbBackend, T, I) where I: IntoIterator<Item = Value>, T: Into<String>
to takes any string SQL - Changed the parameter of method
ConnectOptions::set_schema_search_path(T) where T: Into<String>
to takes any string - Changed the parameter of method
ColumnTrait::like()
,ColumnTrait::not_like()
,ColumnTrait::starts_with()
,ColumnTrait::ends_with()
andColumnTrait::contains()
to takes any string
- Implements
- Added
sea_query::{DynIden, RcOrArc, SeaRc}
to entity prelude #1661 - Added
expr
,exprs
andexpr_as
methods toQuerySelect
trait #1702 - Added
DatabaseConnection::ping
#1627
|db: DatabaseConnection| {
assert!(db.ping().await.is_ok());
db.clone().close().await;
assert!(matches!(db.ping().await, Err(DbErr::ConnectionAcquire)));
}
- Added
TryInsert
that does not panic on empty inserts #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)));
- Insert on conflict do nothing to return Ok #1712
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)));
- Fixed
DeriveActiveEnum
throwing errors becausestring_value
consists non-UAX#31 compliant characters #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,
}
- [sea-orm-cli] Fix Postgres enum arrays #1678
- [sea-orm-cli] The implementation of
Related<R>
withvia
andto
methods will not be generated if there exists multiple paths via an intermediate table #1435 - [sea-orm-cli] fixed entity generation includes partitioned tables #1582, SeaQL/sea-schema#105
- Fixed
ActiveEnum::db_type()
return type does not implementColumnTypeTrait
#1576 - Resolved
insert_many
failing if the models iterator is empty #873
- Supports for partial select of
Option<T>
model field. ANone
value will be filled when the select result does not contain theOption<T>
field instead of throwing an error. #1513 - Replaced
sea-strum
dependency with upstreamstrum
insea-orm
#1535- Added
derive
andstrum
features tosea-orm-macros
- The derive macro
EnumIter
is now shipped bysea-orm-macros
- Added
- Added a new variant
Many
toIdentity
#1508 - Enabled
hashable-value
feature in SeaQuery, thusValue::Float(NaN) == Value::Float(NaN)
would be true #1728, #1743 - The
DeriveActiveEnum
derive macro no longer implementstd::fmt::Display
. You can use the newDeriveDisplay
macro #1726 sea-query/derive
is no longer enabled bysea-orm
, as such,Iden
no longer works as a derive macro (it's still a trait). Instead, we are shipping a new macroDeriveIden
#1740 #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,
}
- Definition of
DbErr::ConnectionAcquire
changed toConnectionAcquire(ConnAcquireErr)
#1737 FromJsonQueryResult
removed from entity prelude
- Upgraded
sqlx
to0.7
#1742 - Upgraded
sea-query
to0.30
#1742 - Upgraded
sea-schema
to0.14
#1742 - Upgraded
syn
to2
#1713 - Upgraded
heck
to0.4
#1520, #1544 - Upgraded
strum
to0.25
#1752 - Upgraded
clap
to4.3
#1468 - Upgraded
ouroboros
to0.17
#1724
- Replaced
bae
withsea-bae
#1739
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.11.1...0.12.1
- Re-export
sea_orm::ConnectionTrait
insea_orm_migration::prelude
#1577 - Support generic structs in
FromQueryResult
derive macro #1464, #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,
}
- Fixes
DeriveActiveEnum
(by qualifyingColumnTypeTrait::def
) #1478 - The CLI command
sea-orm-cli generate entity -u '<DB-URL>'
will now generate the following code for eachBinary
orVarBinary
columns in compact format #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>,
}
- The CLI command
sea-orm-cli generate entity -u '<DB-URL>' --expanded-format
will now generate the following code for eachBinary
orVarBinary
columns in expanded format #1529
impl 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(),
}
}
}
- 2023-02-02:
0.11.0-rc.1
- 2023-02-04:
0.11.0-rc.2
- Simple data loader #1238, #1443
- Transactions Isolation level and Access mode #1230
- Support various UUID formats that are available in
uuid::fmt
module #1325 - Support Vector of enum for Postgres #1210
- Support
ActiveEnum
field as primary key #1414 - Casting columns as a different data type on select, insert and update #1304
- Methods of
ActiveModelBehavior
receive db connection as a parameter #1145, #1328 - Added
execute_unprepared
method toDatabaseConnection
andDatabaseTransaction
#1327 - Added
Select::into_tuple
to select rows as tuples (instead of defining a custom Model) #1311
- Generate
#[serde(skip_deserializing)]
for primary key columns #846, #1186, #1318 - Generate
#[serde(skip)]
for hidden columns #1171, #1320 - Generate entity with extra derives and attributes for model struct #1124, #1321
- Migrations are now performed inside a transaction for Postgres #1379
- Refactor schema module to expose functions for database alteration #1256
- Generate compact entity with
#[sea_orm(column_type = "JsonBinary")]
macro attribute #1346 MockDatabase::append_exec_results()
,MockDatabase::append_query_results()
,MockDatabase::append_exec_errors()
andMockDatabase::append_query_errors()
take any types implementedIntoIterator
trait #1367find_by_id
anddelete_by_id
take anyInto
primary key value #1362QuerySelect::offset
andQuerySelect::limit
takes inInto<Option<u64>>
whereNone
would reset them #1410- Added
DatabaseConnection::close
#1236 - Added
is_null
getter forColumnDef
#1381 - Added
ActiveValue::reset
to convertUnchanged
intoSet
#1177 - Added
QueryTrait::apply_if
to optionally apply a filter #1415 - Added the
sea-orm-internal
feature flag to expose some SQLx types
- Upgrade
axum
to0.6.1
#1285 - Upgrade
sea-query
to0.28
#1366 - Upgrade
sea-query-binder
to0.3
#1366 - Upgrade
sea-schema
to0.11
#1366
- Fixed all clippy warnings as of
1.67.0
#1426 - Removed dependency where not needed #1213
- Disabled default features and enabled only the needed ones #1300
- Cleanup panic and unwrap #1231
- Cleanup the use of
vec!
macro #1367
- [sea-orm-cli] Propagate error on the spawned child processes #1402
- Fixes sea-orm-cli errors exit with error code 0 #1342
- Fixes
DeriveColumn
(by qualifyingIdenStatic::as_str
) #1280 - Prevent returning connections to pool with a positive transaction depth #1283
- Postgres insert many will throw
RecordNotInserted
error if non of them are being inserted #1021- Fixes inserting active models by
insert_many
withon_conflict
anddo_nothing
panics if no rows are inserted on Postgres #899
- Fixes inserting active models by
- Don't call
last_insert_id
if not needed #1403- Fixes hitting 'negative last_insert_rowid' panic with Sqlite #1357
- Noop when update without providing any values #1384
- Fixes Syntax Error when saving active model that sets nothing #1376
- [sea-orm-cli] Enable --universal-time by default #1420
- Added
RecordNotInserted
andRecordNotUpdated
toDbErr
- Added
ConnectionTrait::execute_unprepared
method #1327 - As part of #1311, the required method of
TryGetable
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)?;
..
}
}
- The
ActiveModelBehavior
trait becomes async trait #1328. If you overridden the defaultActiveModelBehavior
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 variantDbErr::RecordNotUpdated
#1425
let 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 bysea_query::ColumnType
#1395- Method
ColumnType::def
was moved toColumnTypeTrait
ColumnType::Binary
becomes a tuple variant which takes in additional optionsea_query::BlobSize
ColumnType::Custom
takes asea_query::DynIden
instead ofString
and thus a new methodcustom
is added (note the lowercase)
- Method
// 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(),
}
}
}
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.10.0...0.11.0
- Inserting active models by
insert_many
withon_conflict
anddo_nothing
panics if no rows are inserted on Postgres #899 - Hitting 'negative last_insert_rowid' panic with Sqlite #1357
- Cast enum values when constructing update many query #1178
- Fixes
DeriveColumn
(by qualifyingIdenStatic::as_str
) #1280 - Prevent returning connections to pool with a positive transaction depth #1283
- [sea-orm-codegen] Skip implementing Related if the same related entity is being referenced by a conjunct relation #1298
- [sea-orm-cli] CLI depends on codegen of the same version #1299
- Add
QuerySelect::columns
method - select multiple columns #1264 - Transactions Isolation level and Access mode #1230
DeriveEntityModel
derive macro: when parsing field type, always treat field withOption<T>
as nullable column #1257
- [sea-orm-cli] Generate
Related
implementation for many-to-many relation with extra columns #1260 - Optimize the default implementation of
TryGetableFromJson::try_get_from_json()
- deserializing intoSelf
directly without the need of a intermediateserde_json::Value
#1249
- Fix DeriveActiveEnum expand enum variant starts with number #1219
- [sea-orm-cli] Generate entity file for specified tables only #1245
- Support appending
DbErr
toMockDatabase
#1241
- Filter rows with
IS IN
enum values expression #1183 - [sea-orm-cli] Generate entity with relation variant order by name of reference table #1229
- [sea-orm-cli] Set search path when initializing Postgres connection for CLI generate entity #1212
- [sea-orm-cli] Generate
_
prefix to enum variant starts with number #1211 - Fix composite key cursor pagination #1216
- The logic for single-column primary key was correct, but for composite keys the logic was incorrect
- Added
Insert::exec_without_returning
#1208
- Remove dependency when not needed #1207
- [sea-orm-rocket] added
sqlx_logging
toConfig
#1192 - Collecting metrics for
query_one/all
#1165 - Use GAT to elide
StreamTrait
lifetime #1161
- corrected the error name
UpdateGetPrimaryKey
#1180
- Update MSRV to 1.65
- [sea-orm-cli] Escape module name defined with Rust keywords #1052
- [sea-orm-cli] Check to make sure migration name doesn't contain hyphen
-
in it #879, #1155 - Support
time
crate for SQLite #995
- [sea-orm-cli] Generate
Related
for m-to-n relation #1075 - [sea-orm-cli] Generate model entity with Postgres Enum field #1153
- [sea-orm-cli] Migrate up command apply all pending migrations #1010
- [sea-orm-cli] Conflicting short flag
-u
when executingmigrate generate
command #1157 - Prefix the usage of types with
sea_orm::
insideDeriveActiveEnum
derive macros #1146, #1154 - [sea-orm-cli] Generate model with
Vec<f32>
orVec<f64>
should not deriveEq
on the model struct #1158
- [sea-orm-cli] [sea-orm-migration] Add
cli
feature to optionally include dependencies that are required by the CLI #978
- Upgrade
sea-schema
to 0.10.2 #1153
- Better error types (carrying SQLx Error) #1002
- Support array datatype in PostgreSQL #1132
- [sea-orm-cli] Generate entity files as a library or module #953
- [sea-orm-cli] Generate a new migration template with name prefix of unix timestamp #947
- [sea-orm-cli] Generate migration in modules #933
- [sea-orm-cli] Generate
DeriveRelation
on emptyRelation
enum #1019 - [sea-orm-cli] Generate entity derive
Eq
if possible #988 - [sea-orm-cli] Run migration on any PostgreSQL schema #1056
- Support
distinct
&distinct_on
expression #902 fn column()
also handle enum type #973- Added
acquire_timeout
onConnectOptions
#897 - [sea-orm-cli]
migrate fresh
command will drop all PostgreSQL types #864, #991 - Better compile error for entity without primary key #1020
- Added blanket implementations of
IntoActiveValue
forOption
values #833 - Added
into_model
&into_json
toCursor
#1112 - Added
set_schema_search_path
method toConnectOptions
for setting schema search path of PostgreSQL connection #1056 - Serialize
time
types asserde_json::Value
#1042 - Implements
fmt::Display
forActiveEnum
#986 - Implements
TryFrom<ActiveModel>
forModel
#990
- Trim spaces when paginating raw SQL #1094
- Replaced
usize
withu64
inPaginatorTrait
#789 - Type signature of
DbErr
changed as a result of #1002 ColumnType::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])
- A new method
array_type
was added toValueType
:
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 toDynIden
:
#[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)
}
...
}
- Documentation grammar fixes #1050
- Replace
dotenv
withdotenvy
in examples #1085 - Exclude test_cfg module from SeaORM #1077
- Support
rocket_okapi
#1071
- Upgrade
sea-query
to 0.26 #985
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.9.0...0.10.0
fn column()
also handle enum type #973- Generate migration in modules #933
- Generate
DeriveRelation
on emptyRelation
enum #1019 - Documentation grammar fixes #1050
- Implement
IntoActiveValue
fortime
types #1041 - Fixed module import for
FromJsonQueryResult
derive macro #1081
- [sea-orm-cli] Migrator CLI handles init and generate commands #931
- [sea-orm-cli] added
with-copy-enums
flag to conditional deriveCopy
onActiveEnum
#936
- Exclude
chrono
default features #950 - Set minimal rustc version to
1.60
#938 - Update
sea-query
to0.26.3
In this minor release, we removed time
v0.1 from the dependency graph
- [sea-orm-cli] Codegen support for
VarBinary
column type #746 - [sea-orm-cli] Generate entity for SYSTEM VERSIONED tables on MariaDB #876
RelationDef
&RelationBuilder
should beSend
&Sync
#898
- Remove unnecessary
async_trait
#737
- Cursor pagination #822
- Custom join on conditions #793
DeriveMigrationName
andsea_orm_migration::util::get_file_stem
#736FromJsonQueryResult
for deserializingJson
from query result #794
- Added
sqlx_logging_level
toConnectOptions
#800 - Added
num_items_and_pages
toPaginator
#768 - Added
TryFromU64
fortime
#849 - Added
Insert::on_conflict
#791 - Added
QuerySelect::join_as
andQuerySelect::join_as_rev
#852 - Include column name in
TryGetError::Null
#853 - [sea-orm-cli] Improve logging #735
- [sea-orm-cli] Generate enum with numeric like variants #588
- [sea-orm-cli] Allow old pending migration to be applied #755
- [sea-orm-cli] Skip generating entity for ignored tables #837
- [sea-orm-cli] Generate code for
time
crate #724 - [sea-orm-cli] Add various blob column types #850
- [sea-orm-cli] Generate entity files with Postgres's schema name #422
- Upgrade
clap
to 3.2 #706 - Upgrade
time
to 0.3 #834 - Upgrade
sqlx
to 0.6 #834 - Upgrade
uuid
to 1.0 #834 - Upgrade
sea-query
to 0.26 #834 - Upgrade
sea-schema
to 0.9 #834
- Refactor stream metrics #778
- [sea-orm-cli] skip checking connection string for credentials #851
SelectTwoMany::one()
has been dropped #813, you can get(Entity, Vec<RelatedEntity>)
by first querying a single model from Entity, then use [ModelTrait::find_related
] on the model.-
We now adopt the weak dependency syntax in Cargo. That means the flags
["sqlx-json", "sqlx-chrono", "sqlx-decimal", "sqlx-uuid", "sqlx-time"]
are not needed and now removed. Instead,with-time
will enablesqlx?/time
only ifsqlx
is already enabled. As a consequence, now the featureswith-json
,with-chrono
,with-rust_decimal
,with-uuid
,with-time
will not be enabled as a side-effect of enablingsqlx
.
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.8.0...0.9.0
- Removed
async-std
from dependency #758
- [sea-orm-cli]
sea migrate generate
to generate a new, empty migration file #656
- Add
max_connections
option to CLI #670 - Derive
Eq
,Clone
forDbErr
#677 - Add
is_changed
toActiveModelTrait
#683
- Fix
DerivePrimaryKey
with custom primary key column name #694 - Fix
DeriveEntityModel
macros override column name #695 - Fix Insert with no value supplied using
DEFAULT
#589
- Migration utilities are moved from sea-schema to sea-orm repo, under a new sub-crate
sea-orm-migration
.sea_schema::migration::prelude
should be replaced bysea_orm_migration::prelude
in all migration files
- Upgrade
sea-query
to 0.24.x,sea-schema
to 0.8.x - Upgrade example to Actix Web 4, Actix Web 3 remains #638
- Added Tonic gRPC example #659
- Upgrade GraphQL example to use axum 0.5.x
- Upgrade axum example to 0.5.x
- Failed to insert row with only default values #420
- Reduce database connections to 1 during codegen #511
- Column names with single letters separated by underscores are concatenated #630
- Update Actix Web examples #639
- Lower function missing #672
- is_changed on active_model #674
- Failing find_with_related with column_name attribute #693
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.7.1...0.8.0
- Fix sea-orm-cli error
- Fix sea-orm cannot build without
with-json
- Update ActiveModel by JSON by @billy1624 in #492
- Supports
time
crate by @billy1624 #602 - Allow for creation of indexes for PostgreSQL and SQLite @nickb937 #593
- Added
delete_by_id
@ShouvikGhosh2048 #590 - Implement
PaginatorTrait
forSelectorRaw
@shinbunbun #617
- Added axum graphql example by @aaronleopold in #587
- Add example for integrate with jsonrpsee by @hunjixin #632
- Codegen add serde derives to enums, if specified by @BenJeau #463
- Codegen Unsigned Integer by @billy1624 #397
- Add
Send
bound toQueryStream
andTransactionStream
by @sebpuetz #471 - Add
Send
toStreamTrait
by @nappa85 #622 sea
as an alternative bin name tosea-orm-cli
by @ZhangHanDong #558
- Fix codegen with Enum in expanded format by @billy1624 #624
- Fixing and testing into_json of various field types by @billy1624 #539
- Exclude
mock
from default features by @billy1624 #562 create_table_from_entity
will no longer create index for MySQL, please use the new methodcreate_index_from_entity
- Describe default value of ActiveValue on document by @Ken-Miura in #556
- community: add axum-book-management by @lz1998 in #564
- Add Backpack to project showcase by @JSH32 in #567
- Add mediarepo to showcase by @Trivernis in #569
- COMMUNITY: add a link to Svix to showcase by @tasn in #537
- Update COMMUNITY.md by @naryand in #570
- Update COMMUNITY.md by @BobAnkh in #568
- Update COMMUNITY.md by @KaniyaSimeji in #566
- Update COMMUNITY.md by @aaronleopold in #565
- Update COMMUNITY.md by @gudaoxuri in #572
- Update Wikijump's entry in COMMUNITY.md by @ammongit in #573
- Update COMMUNITY.md by @koopa1338 in #574
- Update COMMUNITY.md by @gengteng in #580
- Update COMMUNITY.md by @Yama-Tomo in #582
- add oura-postgres-sink to COMMUNITY.md by @rvcas in #594
- Add rust-example-caster-api to COMMUNITY.md by @bkonkle in #623
- orm-cli generated incorrect type for #[sea_orm(primary_key)]. Should be u64. Was i64. #295
- how to update dynamically from json value #346
- Make
DatabaseConnection
Clone
with the default features enabled #438 - Updating multiple fields in a Model by passing a reference #460
- SeaORM CLI not adding serde derives to Enums #461
- sea-orm-cli generates wrong data type for nullable blob #490
- Support the time crate in addition (instead of?) chrono #499
- PaginatorTrait for SelectorRaw #500
- sea_orm::DatabaseConnection should implement
Clone
by default #517 - How do you seed data in migrations using ActiveModels? #522
- Datetime fields are not serialized by
.into_json()
on queries #530 - Update / Delete by id #552
#[sea_orm(indexed)]
only works for MySQL #554sea-orm-cli generate --with-serde
does not work on Postgresql custom type #581sea-orm-cli generate --expanded-format
panic when postgres table contains enum type #614- UUID fields are not serialized by
.into_json()
on queries #619
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.6.0...0.7.0
- Migration Support by @billy1624 in #335
- Support
DateTime<Utc>
&DateTime<Local>
by @billy1624 in #489 - Add
max_lifetime
connection option by @billy1624 in #493
- Model with Generics by @billy1624 in #400
- Add Poem example by @sunli829 in #446
- Codegen
column_name
proc_macro attribute by @billy1624 in #433 - Easy joins with MockDatabase #447 by @cemoktra in #455
- CLI allow generate entity with url without password by @billy1624 in #436
- Support up to 6-ary composite primary key by @billy1624 in #423
- Fix FromQueryResult when Result is redefined by @tasn in #495
- Remove
r#
prefix when derivingFromQueryResult
by @smrtrfszm in #494
- Name conflict of foreign key constraints when two entities have more than one foreign keys by @billy1624 in #417
- Is it possible to have 4 values Composite Key? #352
- Support
DateTime<Utc>
&DateTime<Local>
#381 - Codegen
column_name
proc_macro attribute if column name isn't in snake case #395 - Model with Generics #402
- Foreign key constraint collision when multiple keys exist between the same two tables #405
- sea-orm-cli passwordless database user causes "No password was found in the database url" error #435
- Testing joins with MockDatabase #447
- Surface max_lifetime connection option #475
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.5.0...0.6.0
- Why insert, update, etc return an ActiveModel instead of Model? #289
- Rework
ActiveValue
#321 - Some missing ActiveEnum utilities #338
- First metric and tracing implementation by @nappa85 in #373
- Update sea-orm to depends on SeaQL/sea-query#202 by @billy1624 in #370
- Codegen ActiveEnum & Create Enum From ActiveEnum by @billy1624 in #348
- Axum example: update to Axum v0.4.2 by @ttys3 in #383
- Fix rocket version by @Gabriel-Paulucci in #384
- Insert & Update Return
Model
by @billy1624 in #339 - Rework
ActiveValue
by @billy1624 in #340 - Add wrapper method
ModelTrait::delete
by @billy1624 in #396 - Add docker create script for contributors to setup databases locally by @billy1624 in #378
- Log with tracing-subscriber by @billy1624 in #399
- Codegen SQLite by @billy1624 in #386
- PR without clippy warnings in file changed tab by @billy1624 in #401
- Rename
sea-strum
lib back tostrum
by @billy1624 in #361
ActiveModel::insert
andActiveModel::update
returnModel
instead ofActiveModel
- Method
ActiveModelBehavior::after_save
takesModel
as input instead ofActiveModel
- Rename method
sea_orm::unchanged_active_value_not_intended_for_public_use
tosea_orm::Unchanged
- Rename method
ActiveValue::unset
toActiveValue::not_set
- Rename method
ActiveValue::is_unset
toActiveValue::is_not_set
PartialEq
ofActiveValue
will also check the equality of state instead of just checking the equality of value
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.2...0.5.0
- Delete::many() doesn't work when schema_name is defined #362
- find_with_related panic #374
- How to define the rust type of TIMESTAMP? #344
- Add Table on the generated Column enum #356
Delete::many()
withTableRef
by @billy1624 in #363- Fix related & linked with enum columns by @billy1624 in #376
- Temporary Fix: Handling MySQL & SQLite timestamp columns by @billy1624 in #379
- Add feature to generate table Iden by @Sytten in #360
- Is it possible to have 4 values Composite Key? #352
- [sea-orm-cli] Better handling of relation generations #239
- Add TryFromU64 trait for
DateTime<FixedOffset>
. by @kev0960 in #331 - add offset and limit by @lz1998 in #351
- For some reason the
axum_example
fail to compile by @billy1624 in #355 - Support Up to 6 Values Composite Primary Key by @billy1624 in #353
- Codegen Handle Self Referencing & Multiple Relations to the Same Related Entity by @billy1624 in #347
- Disable SQLx query logging #290
- Code generated by
sea-orm-cli
cannot pass clippy #296 - Should return detailed error message for connection failure #310
DateTimeWithTimeZone
does not implementSerialize
andDeserialize
#319- Support returning clause to avoid database hits #183
- chore: update to Rust 2021 Edition by @sno2 in #273
- Enumeration - 3 by @billy1624 in #274
- Enumeration - 2 by @billy1624 in #261
- Codegen fix clippy warnings by @billy1624 in #303
- Add axum example by @YoshieraHuang in #297
- Enumeration by @billy1624 in #258
- Add
PaginatorTrait
andCountTrait
for more constraints by @YoshieraHuang in #306 - Continue
PaginatorTrait
by @billy1624 in #307 - Refactor
Schema
by @billy1624 in #309 - Detailed connection errors by @billy1624 in #312
- Suppress
ouroboros
missing docs warnings by @billy1624 in #288 with-json
feature requireschrono/serde
by @billy1624 in #320- Pass the argument
entity.table_ref()
instead of justentity
. by @josh-codes in #318 - Unknown types could be a newtypes instead of
ActiveEnum
by @billy1624 in #324 - Returning by @billy1624 in #292
- Refactor
paginate()
&count()
utilities intoPaginatorTrait
. You can use the paginator as usual but you might need to importPaginatorTrait
manually when upgrading from the previous version.use futures::TryStreamExt; use sea_orm::{entity::*, query::*, tests_cfg::cake}; let mut cake_stream = cake::Entity::find() .order_by_asc(cake::Column::Id) .paginate(db, 50) .into_stream(); while let Some(cakes) = cake_stream.try_next().await? { // Do something on cakes: Vec<cake::Model> }
- The helper struct
Schema
convertingEntityTrait
into differentsea-query
statements now has to be initialized withDbBackend
.use sea_orm::{tests_cfg::*, DbBackend, Schema}; use sea_orm::sea_query::TableCreateStatement; // 0.3.x let _: TableCreateStatement = Schema::create_table_from_entity(cake::Entity); // 0.4.x let schema: Schema = Schema::new(DbBackend::MySql); let _: TableCreateStatement = schema.create_table_from_entity(cake::Entity);
- When performing insert or update operation on
ActiveModel
against PostgreSQL,RETURNING
clause will be used to perform select in a single SQL statement.// For PostgreSQL cake::ActiveModel { name: Set("Apple Pie".to_owned()), ..Default::default() } .insert(&postgres_db) .await?; assert_eq!( postgres_db.into_transaction_log(), vec![Transaction::from_sql_and_values( DbBackend::Postgres, r#"INSERT INTO "cake" ("name") VALUES ($1) RETURNING "id", "name""#, vec!["Apple Pie".into()] )]);
// For MySQL & SQLite cake::ActiveModel { name: Set("Apple Pie".to_owned()), ..Default::default() } .insert(&other_db) .await?; assert_eq!( other_db.into_transaction_log(), vec![ Transaction::from_sql_and_values( DbBackend::MySql, r#"INSERT INTO `cake` (`name`) VALUES (?)"#, vec!["Apple Pie".into()] ), Transaction::from_sql_and_values( DbBackend::MySql, r#"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` = ? LIMIT ?"#, vec![15.into(), 1u64.into()] )]);
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.2...0.4.0
- Support for BYTEA Postgres primary keys #286
- Documentation for sea-orm by @charleschege in #280
- Support
Vec<u8>
primary key by @billy1624 in #287
(We are changing our Changelog format from now on)
(The following is generated by GitHub)
- Changed manual url parsing to use Url crate by @AngelOnFira in #253
- Test self referencing relation by @billy1624 in #256
- Unify case-transform using the same crate by @billy1624 in #264
- CI cleaning by @AngelOnFira in #263
- CI install sea-orm-cli in debug mode by @billy1624 in #265
https://www.sea-ql.org/SeaORM/blog/2021-10-15-whats-new-in-0.3.0
- Built-in Rocket support
ConnectOptions
let mut opt = ConnectOptions::new("protocol://username:password@host/database".to_owned());
opt.max_connections(100)
.min_connections(5)
.connect_timeout(Duration::from_secs(8))
.idle_timeout(Duration::from_secs(8));
let db = Database::connect(opt).await?;
- [#211] Throw error if none of the db rows are affected
assert_eq!(
Update::one(cake::ActiveModel {
name: Set("Cheese Cake".to_owned()),
..model.into_active_model()
})
.exec(&db)
.await,
Err(DbErr::RecordNotFound(
"None of the database rows are affected".to_owned()
))
);
// update many remains the same
assert_eq!(
Update::many(cake::Entity)
.col_expr(cake::Column::Name, Expr::value("Cheese Cake".to_owned()))
.filter(cake::Column::Id.eq(2))
.exec(&db)
.await,
Ok(UpdateResult { rows_affected: 0 })
);
- [#223]
ActiveValue::take()
&ActiveValue::into_value()
withoutunwrap()
- [#205] Drop
Default
trait bound ofPrimaryKeyTrait::ValueType
- [#222] Transaction & streaming
- [#210] Update
ActiveModelBehavior
API - [#240] Add derive
DeriveIntoActiveModel
andIntoActiveValue
trait - [#237] Introduce optional serde support for model code generation
- [#246] Add
#[automatically_derived]
to all derived implementations
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.2.6...0.3.0
- [#224] [sea-orm-cli] Date & Time column type mapping
- Escape rust keywords with
r#
raw identifier
- [#227] Resolve "Inserting actual none value of Option results in panic"
- [#219] [sea-orm-cli] Add
--tables
option - [#189] Add
debug_query
anddebug_query_stmt
macro
https://www.sea-ql.org/SeaORM/blog/2021-10-01-whats-new-in-0.2.4
- [#186] [sea-orm-cli] Foreign key handling
- [#191] [sea-orm-cli] Unique key handling
- [#182]
find_linked
join with alias - [#202] Accept both
postgres://
andpostgresql://
- [#208] Support fetching T, (T, U), (T, U, P) etc
- [#209] Rename column name & column enum variant
- [#207] Support
chrono::NaiveDate
&chrono::NaiveTime
- Support
Condition::not
(from sea-query)
- [#152] DatabaseConnection impl
Clone
- [#175] Impl
TryGetableMany
for different types of generics - Codegen
TimestampWithTimeZone
fixup
- [#105] Compact entity format
- [#132] Add ActiveModel
insert
&update
- [#129] Add
set
method toUpdateMany
- [#118] Initial lock support
- [#167] Add
FromQueryResult::find_by_statement
- Update dependencies
- [#37] Rocket example
- [#114]
log
crate andenv-logger
- [#103]
InsertResult
to return the primary key's type - [#89] Represent several relations between same types by
Linked
- [#59] Transforming an Entity into
TableCreateStatement
Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.1.3...0.2.0
- [#108] Remove impl TryGetable for Option
- [#68] Added
DateTimeWithTimeZone
as supported attribute type - [#70] Generate arbitrary named entity
- [#80] Custom column name
- [#81] Support join on multiple columns
- [#99] Implement FromStr for ColumnTrait
- Early release of SeaORM