Skip to content

Latest commit

 

History

History
1089 lines (843 loc) · 49.4 KB

CHANGELOG.md

File metadata and controls

1089 lines (843 loc) · 49.4 KB

Changelog

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.

0.12.0 - Pending

New Features

  • Supports for partial select of Option<T> model field. A None value will be filled when the select result does not contain the Option<T> field without throwing an error. SeaQL/sea-orm#1513
customer::ActiveModel {
    name: Set("Alice".to_owned()),
    notes: Set(Some("Want to communicate with Bob".to_owned())),
    ..Default::default()
}
.save(db)
.await?;

// The `notes` field was intentionally leaved out
let customer = Customer::find()
    .select_only()
    .column(customer::Column::Id)
    .column(customer::Column::Name)
    .one(db)
    .await
    .unwrap();

// The select result does not contain `notes` field.
// Since it's of type `Option<String>`, it'll be `None` and no error will be thrown.
assert_eq!(customers.notes, None);

Enhancements

  • Added Migration::name() and Migration::status() getters for the name and status of sea_orm_migration::Migration SeaQL/sea-orm#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);

Upgrades

Breaking changes

  • Supports for partial select of Option<T> model field. A None value will be filled when the select result does not contain the Option<T> field without throwing an error. SeaQL/sea-orm#1513

0.11.2 - Pending

Enhancements

0.11.1 - 2023-03-10

Bug Fixes

  • Fixes DeriveActiveEnum (by qualifying ColumnTypeTrait::def) SeaQL/sea-orm#1478
  • The CLI command sea-orm-cli generate entity -u '<DB-URL>' will now generate the following code for each Binary or VarBinary columns in compact format SeaQL/sea-orm#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 each Binary or VarBinary columns in expanded format SeaQL/sea-orm#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(),
        }
    }
}

0.11.0 - 2023-02-07

  • 2023-02-02: 0.11.0-rc.1
  • 2023-02-04: 0.11.0-rc.2

New Features

SeaORM Core

SeaORM CLI

SeaORM Migration

Enhancements

  • Refactor schema module to expose functions for database alteration SeaQL/sea-orm#1256
  • Generate compact entity with #[sea_orm(column_type = "JsonBinary")] macro attribute SeaQL/sea-orm#1346
  • MockDatabase::append_exec_results(), MockDatabase::append_query_results(), MockDatabase::append_exec_errors() and MockDatabase::append_query_errors() take any types implemented IntoIterator trait SeaQL/sea-orm#1367
  • find_by_id and delete_by_id take any Into primary key value SeaQL/sea-orm#1362
  • QuerySelect::offset and QuerySelect::limit takes in Into<Option<u64>> where None would reset them SeaQL/sea-orm#1410
  • Added DatabaseConnection::close SeaQL/sea-orm#1236
  • Added is_null getter for ColumnDef SeaQL/sea-orm#1381
  • Added ActiveValue::reset to convert Unchanged into Set SeaQL/sea-orm#1177
  • Added QueryTrait::apply_if to optionally apply a filter SeaQL/sea-orm#1415
  • Added the sea-orm-internal feature flag to expose some SQLx types

Upgrades

House Keeping

Bug Fixes

Breaking Changes

// 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 SeaQL/sea-orm#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 SeaQL/sea-orm#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 by sea_query::ColumnType SeaQL/sea-orm#1395
    • Method ColumnType::def was moved to ColumnTypeTrait
    • ColumnType::Binary becomes a tuple variant which takes in additional option sea_query::BlobSize
    • ColumnType::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(),
        }
    }
}

Miscellaneous

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.10.0...0.11.0

0.10.7 - 2023-01-19

Bug Fixes

  • Inserting active models by insert_many with on_conflict and do_nothing panics if no rows are inserted on Postgres SeaQL/sea-orm#899
  • Hitting 'negative last_insert_rowid' panic with Sqlite SeaQL/sea-orm#1357

0.10.6 - 2022-12-23

Enhancements

Bug Fixes

  • Fixes DeriveColumn (by qualifying IdenStatic::as_str) SeaQL/sea-orm#1280
  • Prevent returning connections to pool with a positive transaction depth SeaQL/sea-orm#1283
  • [sea-orm-codegen] Skip implementing Related if the same related entity is being referenced by a conjunct relation SeaQL/sea-orm#1298
  • [sea-orm-cli] CLI depends on codegen of the same version SeaQL/sea-orm#1299

0.10.5 - 2022-12-02

New Features

Bug Fixes

  • DeriveEntityModel derive macro: when parsing field type, always treat field with Option<T> as nullable column SeaQL/sea-orm#1257

Enhancements

  • [sea-orm-cli] Generate Related implementation for many-to-many relation with extra columns SeaQL/sea-orm#1260
  • Optimize the default implementation of TryGetableFromJson::try_get_from_json() - deserializing into Self directly without the need of a intermediate serde_json::Value SeaQL/sea-orm#1249

0.10.4 - 2022-11-24

Bug Fixes

Enhancements

0.10.3 - 2022-11-14

Bug Fixes

  • [sea-orm-cli] Set search path when initializing Postgres connection for CLI generate entity SeaQL/sea-orm#1212
  • [sea-orm-cli] Generate _ prefix to enum variant starts with number SeaQL/sea-orm#1211
  • Fix composite key cursor pagination SeaQL/sea-orm#1216
    • The logic for single-column primary key was correct, but for composite keys the logic was incorrect

Enhancements

House Keeping

0.10.2 - 2022-11-06

Enhancements

Bug Fixes

Upgrades

  • Update MSRV to 1.65

0.10.1 - 2022-10-27

Enhancements

Bug Fixes

House Keeping

  • [sea-orm-cli] [sea-orm-migration] Add cli feature to optionally include dependencies that are required by the CLI SeaQL/sea-orm#978

Upgrades

0.10.0 - 2022-10-23

New Features

Enhancements

Bug Fixes

Breaking Changes

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 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)
    }
    ...
}

House Keeping

Integration

Upgrades

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.9.0...0.10.0

0.9.3 - 2022-09-30

Enhancements

Bug Fixes

0.9.2 - 2022-08-20

Enhancements

  • [sea-orm-cli] Migrator CLI handles init and generate commands SeaQL/sea-orm#931
  • [sea-orm-cli] added with-copy-enums flag to conditional derive Copy on ActiveEnum SeaQL/sea-orm#936

House Keeping

Notes

In this minor release, we removed time v0.1 from the dependency graph

0.9.1 - 2022-07-22

Enhancements

Bug Fixes

House Keeping

0.9.0 - 2022-07-17

New Features

Enhancements

Upgrades

House Keeping

Bug Fixes

Breaking Changes

  • SelectTwoMany::one() has been dropped SeaQL/sea-orm#813, you can get (Entity, Vec<RelatedEntity>) by first querying a single model from Entity, then use [ModelTrait::find_related] on the model.
  • Feature flag revamp

    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 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-migration 0.8.3

0.8.0 - 2022-05-10

New Features

  • [sea-orm-cli] sea migrate generate to generate a new, empty migration file SeaQL/sea-orm#656

Enhancements

Bug Fixes

Breaking Changes

  • 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 by sea_orm_migration::prelude in all migration files

Upgrades

  • Upgrade sea-query to 0.24.x, sea-schema to 0.8.x
  • Upgrade example to Actix Web 4, Actix Web 3 remains SeaQL/sea-orm#638
  • Added Tonic gRPC example SeaQL/sea-orm#659
  • Upgrade GraphQL example to use axum 0.5.x
  • Upgrade axum example to 0.5.x

Fixed Issues

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.7.1...0.8.0

0.7.1 - 2022-03-26

  • Fix sea-orm-cli error
  • Fix sea-orm cannot build without with-json

0.7.0 - 2022-03-26

New Features

Enhancements

Bug Fixes

Breaking Changes

  • Exclude mock from default features by @billy1624 SeaQL/sea-orm#562
  • create_table_from_entity will no longer create index for MySQL, please use the new method create_index_from_entity

Documentations

Fixed Issues

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.6.0...0.7.0

0.6.0 - 2022-02-07

New Features

Enhancements

Bug Fixes

Breaking Changes

  • Name conflict of foreign key constraints when two entities have more than one foreign keys by @billy1624 in SeaQL/sea-orm#417

Fixed Issues

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.5.0...0.6.0

0.5.0 - 2022-01-01

Fixed Issues

Merged PRs

Breaking Changes

  • ActiveModel::insert and ActiveModel::update return Model instead of ActiveModel
  • Method ActiveModelBehavior::after_save takes Model as input instead of ActiveModel
  • Rename method sea_orm::unchanged_active_value_not_intended_for_public_use to sea_orm::Unchanged
  • Rename method ActiveValue::unset to ActiveValue::not_set
  • Rename method ActiveValue::is_unset to ActiveValue::is_not_set
  • PartialEq of ActiveValue 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

0.4.2 - 2021-12-12

Fixed Issues

Merged PRs

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.1...0.4.2

0.4.1 - 2021-12-05

Fixed Issues

Merged PRs

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.0...0.4.1

0.4.0 - 2021-11-19

Fixed Issues

Merged PRs

Breaking Changes

  • Refactor paginate() & count() utilities into PaginatorTrait. You can use the paginator as usual but you might need to import PaginatorTrait 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 converting EntityTrait into different sea-query statements now has to be initialized with DbBackend.
    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

0.3.2 - 2021-11-03

Fixed Issues

Merged PRs

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.1...0.3.2

0.3.1 - 2021-10-23

(We are changing our Changelog format from now on)

Fixed Issues

(The following is generated by GitHub)

Merged PRs

Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.0...0.3.1

0.3.0 - 2021-10-15

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() without unwrap()
  • [#205] Drop Default trait bound of PrimaryKeyTrait::ValueType
  • [#222] Transaction & streaming
  • [#210] Update ActiveModelBehavior API
  • [#240] Add derive DeriveIntoActiveModel and IntoActiveValue trait
  • [#237] Introduce optional serde support for model code generation
  • [#246] Add #[automatically_derived] to all derived implementations

0.2.6 - 2021-10-09

  • [#224] [sea-orm-cli] Date & Time column type mapping
  • Escape rust keywords with r# raw identifier

0.2.5 - 2021-10-06

  • [#227] Resolve "Inserting actual none value of Option results in panic"
  • [#219] [sea-orm-cli] Add --tables option
  • [#189] Add debug_query and debug_query_stmt macro

0.2.4 - 2021-10-01

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:// and postgresql://
  • [#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)

0.2.3 - 2021-09-22

  • [#152] DatabaseConnection impl Clone
  • [#175] Impl TryGetableMany for different types of generics
  • Codegen TimestampWithTimeZone fixup

0.2.2 - 2021-09-18

  • [#105] Compact entity format
  • [#132] Add ActiveModel insert & update
  • [#129] Add set method to UpdateMany
  • [#118] Initial lock support
  • [#167] Add FromQueryResult::find_by_statement

0.2.1 - 2021-09-04

  • Update dependencies

0.2.0 - 2021-09-03

  • [#37] Rocket example
  • [#114] log crate and env-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

0.1.3 - 2021-08-30

  • [#108] Remove impl TryGetable for Option

0.1.2 - 2021-08-23

  • [#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

0.1.1 - 2021-08-08

  • Early release of SeaORM