Releases: SeaQL/sea-orm
Releases Β· SeaQL/sea-orm
0.11.1
Bug Fixes
- 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(),
}
}
}
Full Changelog: 0.11.0...0.11.1
0.11.0
https://www.sea-ql.org/blog/2023-02-08-whats-new-in-seaorm-0.11.0/
New Features
SeaORM Core
- 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
SeaORM CLI
- 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
SeaORM Migration
- Migrations are now performed inside a transaction for Postgres #1379
Enhancements
- 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
Upgrades
- 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
House Keeping
- 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
Bug Fixes
- [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
Breaking changes
- [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
ActiveModelBehaviour
trait becomes async trait #1328.
If you overridden the defaultActiveModelBehaviour
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(),
}
}
}
Miscellaneous
New Contributors
- @goto-eof made their first contribution in #1234
- @tdejager made their first contribution in #1240
- @limjiayi made their first contribution in #1260
- @hut8 made their first contribution in #1302
- @as-cii made their first contribution in #1283
- @karatakis made their first contribution in #1238
- @LeoniePhiline made their first contribution in #1391
- @daniel-samson made their first contribution in #1405
- @Diwakar-Gupta made their first contribution in #1402
- @cemremengu made their first contribution in #1428
- @ippsav made their first contribution in #1430
Full Changelog: 0.10.0...0.11.0
0.11.0-rc.2
See 0.11.0 release notes
0.11.0-rc.1
See 0.11.0 release notes
0.10.7
0.10.6
Enhancements
- Cast enum values when constructing update many query #1178
Bug Fixes
- 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
Full Changelog: 0.10.5...0.10.6
0.10.5
New Features
- Add
QuerySelect::columns
method - select multiple columns #1264 - Transactions Isolation level and Access mode #1230
Bug Fixes
DeriveEntityModel
derive macro: when parsing field type, always treat field withOption<T>
as nullable column #1257
Enhancements
- [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
Full Changelog: 0.10.4...0.10.5
0.10.4
Bug Fixes
- 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
Enhancements
- Filter rows with
IS IN
enum values expression #1183 - [sea-orm-cli] Generate entity with relation variant order by name of reference table #1229
Full Changelog: 0.10.3...0.10.4
0.10.3
Bug Fixes
- [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
Enhancements
- Added
Insert::exec_without_returning
#1208
House Keeping
- Remove dependency when not needed #1207
Full Changelog: 0.10.2...0.10.3
0.10.2
Enhancements
- [sea-orm-rocket] added
sqlx_logging
toConfig
#1192 - Collecting metrics for
query_one/all
#1165 - use GAT to elide
StreamTrait
lifetime #1161
Bug Fixes
- corrected the error name
UpdateGetPrimaryKey
#1180
Upgrades
- Update MSRV to 1.65
New Contributors
- @phidiaLam made their first contribution in #1160
- @sousandrei made their first contribution in #1168
- @frederikhors made their first contribution in #1174
- @jayay made their first contribution in #1192
Full Changelog: 0.10.1...0.10.2