Releases: SeaQL/sea-orm
Releases Β· SeaQL/sea-orm
1.1.1
Enhancements
- [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
Enhancements
- [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
Upgrades
- 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
House keeping
1.1.0-rc.3
Enhancements
- Add
ColumnDef::get_column_default
getter #2387
1.1.0-rc.2
Enhancements
- [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
Upgrades
House keeping
1.0.1
New Features
- Added
ConnectOptions::connect_lazy
for creating DB connection pools without establishing connections up front #2268
Breaking Changes
- 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
Bug Fixes
- [sea-orm-codegen] Fix
ColumnType
to Rust type resolution #2313
1.1.0-rc.1
1.0.0
New Features
- 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
}
// ...
}
Enhancements
- 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(" ")
);
Bug Fixes
- 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
Breaking changes
- 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
Upgrades
- 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
House keeping
- Reduce warnings in integration tests #2177
- Improved Actix example to return 404 not found on unexpected inputs #2140
- Re-enable
rocket_okapi
example #2136
New Contributors
- @4kimov made their first contribution in #2103
- @ryankopf made their first contribution in #2064
- @ikka0426 made their first contribution in #2140
- @m4tx made their first contribution in #2136
- @AlbertMarashi made their first contribution in #1665
- @bamidev made their first contribution in #2171
- @jharrilim made their first contribution in #2148
- @Hmikihiro made their first contribution in #2177
- @RafDevX made their first contribution in #2199
- @jdrouet made their first contribution in #2241
- @workingjubilee made their first contribution in #2267
Full Changelog: 0.12.15...1.0.0
1.0.0-rc.7
1.0.0-rc.6
1.0.0-rc.5
New Features
- 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
}