From 02868399e705a8e4bf84b0573e4b882096b1ba6e Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sun, 17 Jul 2022 17:18:15 +0800 Subject: [PATCH] Edit --- SeaORM/blog/2022-07-13-whats-new-in-0.9.0.md | 879 ------------------- 1 file changed, 879 deletions(-) delete mode 100644 SeaORM/blog/2022-07-13-whats-new-in-0.9.0.md diff --git a/SeaORM/blog/2022-07-13-whats-new-in-0.9.0.md b/SeaORM/blog/2022-07-13-whats-new-in-0.9.0.md deleted file mode 100644 index 43608d334e8..00000000000 --- a/SeaORM/blog/2022-07-13-whats-new-in-0.9.0.md +++ /dev/null @@ -1,879 +0,0 @@ ---- -slug: 2022-07-13-whats-new-in-0.9.0 -title: What's new in SeaORM 0.9.0 -author: SeaQL Team -author_title: Chris Tsang -author_url: https://github.com/SeaQL -author_image_url: https://www.sea-ql.org/SeaORM/img/SeaQL.png -tags: [news] ---- - -🎉 We are pleased to release SeaORM [`0.9.0`](https://github.com/SeaQL/sea-orm/releases/tag/0.9.0) today! Here are some feature highlights 🌟: - -## Dependency Upgrades - -[[#834](https://github.com/SeaQL/sea-orm/pull/834)] We have upgraded a few major dependencies: -- Upgrade [`sqlx`](https://github.com/launchbadge/sqlx) to 0.6 -- Upgrade [`time`](https://github.com/time-rs/time) to 0.3 -- Upgrade [`uuid`](https://github.com/uuid-rs/uuid) to 1.0 -- Upgrade [`sea-query`](https://github.com/SeaQL/sea-query) to 0.26 -- Upgrade [`sea-schema`](https://github.com/SeaQL/sea-schema) to 0.9 - -Note that you might need to upgrade the corresponding dependency on your application as well. - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- Rob Gilson -
-
-
-
-
-
- - - -
-
- boraarslan -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- Billy Chan -
-
-
-
-
-
-
- -## Cursor Pagination - -[[#822](https://github.com/SeaQL/sea-orm/pull/822)] Paginate models based on column(s) such as the primary key. - -```rust -// Create a cursor that order by `cake`.`id` -let mut cursor = cake::Entity::find().cursor_by(cake::Column::Id); - -// Filter paginated result by `cake`.`id` > 1 AND `cake`.`id` < 100 -cursor.after(1).before(100); - -// Get first 10 rows (order by `cake`.`id` ASC) -let rows: Vec = cursor.first(10).all(db).await?; - -// Get last 10 rows (order by `cake`.`id` DESC but rows are returned in ascending order) -let rows: Vec = cursor.last(10).all(db).await?; -``` - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- Lucas Berezy -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- Émile Fugulin -
-
-
-
-
-
- - - -
-
- Billy Chan -
-
-
-
-
-
-
- -## Insert On Conflict - -[[#791](https://github.com/SeaQL/sea-orm/pull/791)] Insert an active model with on conflict behaviour. - -```rust -let orange = cake::ActiveModel { - id: ActiveValue::set(2), - name: ActiveValue::set("Orange".to_owned()), -}; - -// On conflict do nothing: -// - INSERT INTO "cake" ("id", "name") VALUES (2, 'Orange') ON CONFLICT ("name") DO NOTHING -cake::Entity::insert(orange.clone()) - .on_conflict( - sea_query::OnConflict::column(cake::Column::Name) - .do_nothing() - .to_owned() - ) - .exec(db) - .await?; - -// On conflict do update: -// - INSERT INTO "cake" ("id", "name") VALUES (2, 'Orange') ON CONFLICT ("name") DO UPDATE SET "name" = "excluded"."name" -cake::Entity::insert(orange) - .on_conflict( - sea_query::OnConflict::column(cake::Column::Name) - .update_column(cake::Column::Name) - .to_owned() - ) - .exec(db) - .await?; -``` - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- baoyachi. Aka Rust Hairy crabs -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- liberwang1013 -
-
-
-
-
-
-
- -## Join Table with Custom Conditions and Table Alias - -[[#793](https://github.com/SeaQL/sea-orm/pull/793), [#852](https://github.com/SeaQL/sea-orm/pull/852)] Click [Custom Join Conditions](/SeaORM/docs/next/relation/custom-join-condition) and [Custom Joins](/SeaORM/docs/next/advanced-query/custom-joins) to learn more. - -```rust -assert_eq!( - cake::Entity::find() - .column_as( - Expr::tbl(Alias::new("fruit_alias"), fruit::Column::Name).into_simple_expr(), - "fruit_name" - ) - .join_as( - JoinType::LeftJoin, - cake::Relation::Fruit - .def() - .on_condition(|_left, right| { - Expr::tbl(right, fruit::Column::Name) - .like("%tropical%") - .into_condition() - }), - Alias::new("fruit_alias") - ) - .build(DbBackend::MySql) - .to_string(), - [ - "SELECT `cake`.`id`, `cake`.`name`, `fruit_alias`.`name` AS `fruit_name` FROM `cake`", - "LEFT JOIN `fruit` AS `fruit_alias` ON `cake`.`id` = `fruit_alias`.`cake_id` AND `fruit_alias`.`name` LIKE '%tropical%'", - ] - .join(" ") -); -``` - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- Chris Tsang -
-
-
-
-
-
- - - -
-
- Tuetuopay -
-
-
-
-
-
- - - -
-
- Loïc -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- Billy Chan -
-
-
-
-
-
- - - -
-
- Matt -
-
-
-
-
-
- - - -
-
- liberwang1013 -
-
-
-
-
-
-
- -## (de)serialize Custom JSON Type - -[[#794](https://github.com/SeaQL/sea-orm/pull/794)] JSON stored in the database could be deserialized into custom struct in Rust. - -```rust -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "json_struct")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, - // JSON column defined in `serde_json::Value` - pub json: Json, - // JSON column defined in custom struct - pub json_value: KeyValue, - pub json_value_opt: Option, -} - -// The custom struct much derive `FromJsonQueryResult`, `Serialize` and `Deserialize` -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, FromJsonQueryResult)] -pub struct KeyValue { - pub id: i32, - pub name: String, - pub price: f32, - pub notes: Option, -} -``` - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- Mara Schulke -
-
-
-
-
-
- - - -
-
- Chris Tsang -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- Billy Chan -
-
-
-
-
-
-
- -## Derived Migration Name - -[[#736](https://github.com/SeaQL/sea-orm/pull/736)] Introduce `DeriveMigrationName` procedural macros to infer migration name from the file name. - -```rust -use sea_orm_migration::prelude::*; - -// Used to be... -pub struct Migration; - -impl MigrationName for Migration { - fn name(&self) -> &str { - "m20220120_000001_create_post_table" - } -} - -// Now... derive `DeriveMigrationName`, -// no longer have to specify the migration name explicitly -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( ... ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table( ... ) - .await - } -} -``` - -
-
-
-
- Proposed by: -
-
-
-
-
- - - -
-
- Chris Tsang -
-
-
-
-
-
-
-
-
- Contributed by: -
-
-
-
-
- - - -
-
- smonv -
-
-
-
-
-
- - - -
-
- Lukas Potthast -
-
-
-
-
-
- - - -
-
- Billy Chan -
-
-
-
-
-
-
- -## SeaORM CLI Updates - -- [[#735](https://github.com/SeaQL/sea-orm/pull/735)] Improve logging of generate entity command -- [[#588](https://github.com/SeaQL/sea-orm/pull/588)] Generate enum with numeric like variants -- [[#755](https://github.com/SeaQL/sea-orm/pull/755)] Allow old pending migration to be applied -- [[#837](https://github.com/SeaQL/sea-orm/pull/837)] Skip generating entity for ignored tables -- [[#724](https://github.com/SeaQL/sea-orm/pull/724)] Generate code for `time` crate -- [[#850](https://github.com/SeaQL/sea-orm/pull/850)] Add various blob column types -- [[#422](https://github.com/SeaQL/sea-orm/pull/422)] Generate entity files with Postgres's schema name -- [[#851](https://github.com/SeaQL/sea-orm/pull/851)] Skip checking connection string for credentials - -
-
- Proposed & Contributed by: -
-
-
- - - -
-
- ttys3 -
-
-
-
-
-
- - - -
-
- kyoto7250 -
-
-
-
-
-
- - - -
-
- yb3616 -
-
-
-
-
-
- - - -
-
- Émile Fugulin -
-
-
-
-
-
- - - -
-
- Bastian -
-
-
-
-
-
- - - -
-
- Nahua -
-
-
-
-
-
- - - -
-
- Mike -
-
-
-
-
-
- - - -
-
- Frank Horvath -
-
-
-
-
-
- - - -
-
- Maikel Wever -
-
-
-
-
- -## Minor Enhancements - -- [[#800](https://github.com/SeaQL/sea-orm/pull/800)] Added `sqlx_logging_level` to `ConnectOptions` -- [[#768](https://github.com/SeaQL/sea-orm/pull/768)] Added `num_items_and_pages` to `Paginator` -- [[#849](https://github.com/SeaQL/sea-orm/pull/849)] Added `TryFromU64` for `time` -- [[#853](https://github.com/SeaQL/sea-orm/pull/853)] Include column name in `TryGetError::Null` -- [[#778](https://github.com/SeaQL/sea-orm/pull/778)] Refactor stream metrics - -
-
- Proposed & Contributed by: -
-
-
- - - -
-
- SandaruKasa -
-
-
-
-
-
- - - -
-
- Eric -
-
-
-
-
-
- - - -
-
- Émile Fugulin -
-
-
-
-
-
- - - -
-
- Renato Dinhani -
-
-
-
-
-
- - - -
-
- kyoto7250 -
-
-
-
-
-
- - - -
-
- Marco Napetti -
-
-
-
-
- -## Integration Examples - -SeaORM plays well with the other crates in the async ecosystem. It can be integrated easily with common RESTful frameworks and also gRPC frameworks. More examples [wanted](https://github.com/SeaQL/sea-orm/issues/269)! - -- [Rocket Example](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example) -- [Actix Example](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example) -- [Axum Example](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example) -- [Poem Example](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example) -- [GraphQL Example](https://github.com/SeaQL/sea-orm/tree/master/examples/graphql_example) -- [jsonrpsee Example](https://github.com/SeaQL/sea-orm/tree/master/examples/jsonrpsee_example) -- [Tonic Example](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example) - -## Who's using SeaORM? - -The following products are powered by SeaORM: - - - - - - - - - -


A lightweight web security auditing toolkit

A Bitcoin lightning node implementation

The enterprise ready webhooks service
- -SeaORM is the foundation of [StarfishQL](https://github.com/SeaQL/starfish-ql), an experimental graph database and query engine. - -For more projects, see [Built with SeaORM](https://github.com/SeaQL/sea-orm/blob/master/COMMUNITY.md#built-with-seaorm). - -## Sponsor - -Our [GitHub Sponsor](https://github.com/sponsors/SeaQL) profile is up! If you feel generous, a small donation will be greatly appreciated. - -A big shout out to our sponsors 😇: - -
-
-
- - - -
-
- Émile Fugulin -
-
-
-
-
-
- - - -
-
- Dean Sheather -
-
-
-
-
-
- - - -
-
- Shane Sveller -
-
-
-
-
-
- - - -
-
- Sakti Dwi Cahyono -
-
-
-
-
-
- - - -
-
- Unnamed Sponsor -
-
-
-
-
-
- - - -
-
- Unnamed Sponsor -
-
-
-
-
- -## Community - -SeaQL is a community driven project. We welcome you to participate, contribute and together build for Rust's future. - -Here is the roadmap for SeaORM [`0.10.x`](https://github.com/SeaQL/sea-orm/milestone/10). - -## GSoC 2022 - -We are super excited to be selected as a Google Summer of Code 2022 [mentor organization](https://summerofcode.withgoogle.com/programs/2022/organizations/seaql). The application is now closed, but the program is about to start! If you have thoughts over how we are going to implement the [project ideas](https://github.com/SeaQL/summer-of-code/tree/main/2022), feel free to participate in the discussion. Click [here](/SeaORM/blog/2022-06-02-summer-of-code-2022-intro) to learn more about our contributors and mentors in Summer of Code 2022.