Changelog
This commit is contained in:
parent
92ea837cdf
commit
5e5aa7cbd1
11
CHANGELOG.md
11
CHANGELOG.md
@ -536,6 +536,16 @@ impl ColumnTrait for Column {
|
|||||||
* Added the `sea-orm-internal` feature flag to expose some SQLx types
|
* Added the `sea-orm-internal` feature flag to expose some SQLx types
|
||||||
* Added `DatabaseConnection::get_*_connection_pool()` for accessing the inner SQLx connection pool https://github.com/SeaQL/sea-orm/pull/1297
|
* Added `DatabaseConnection::get_*_connection_pool()` for accessing the inner SQLx connection pool https://github.com/SeaQL/sea-orm/pull/1297
|
||||||
* Re-exporting SQLx errors https://github.com/SeaQL/sea-orm/pull/1434
|
* Re-exporting SQLx errors https://github.com/SeaQL/sea-orm/pull/1434
|
||||||
|
* Added `TryInsert` that does not panic on empty inserts https://github.com/SeaQL/sea-orm/pull/1708
|
||||||
|
```rust
|
||||||
|
// now, you can do:
|
||||||
|
let empty_insert = Bakery::insert_many(std::iter::empty())
|
||||||
|
.on_empty_do_nothing()
|
||||||
|
.exec(db)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert!(matches!(empty_insert, TryInsertResult::Empty));
|
||||||
|
```
|
||||||
|
|
||||||
### Upgrades
|
### Upgrades
|
||||||
|
|
||||||
@ -564,6 +574,7 @@ impl ColumnTrait for Column {
|
|||||||
* Fixes hitting 'negative last_insert_rowid' panic with Sqlite https://github.com/SeaQL/sea-orm/issues/1357
|
* Fixes hitting 'negative last_insert_rowid' panic with Sqlite https://github.com/SeaQL/sea-orm/issues/1357
|
||||||
* Noop when update without providing any values https://github.com/SeaQL/sea-orm/pull/1384
|
* Noop when update without providing any values https://github.com/SeaQL/sea-orm/pull/1384
|
||||||
* Fixes Syntax Error when saving active model that sets nothing https://github.com/SeaQL/sea-orm/pull/1376
|
* Fixes Syntax Error when saving active model that sets nothing https://github.com/SeaQL/sea-orm/pull/1376
|
||||||
|
* Resolved `insert_many` failing if the models iterator is empty https://github.com/SeaQL/sea-orm/issues/873
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub user_id: Option<i32> ,
|
pub user_id: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
@ -15,7 +15,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "NoAction",
|
on_update = "NoAction",
|
||||||
on_delete = "NoAction",
|
on_delete = "NoAction"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
#[sea_orm(has_many = "super::users_saved_bills::Entity")]
|
#[sea_orm(has_many = "super::users_saved_bills::Entity")]
|
||||||
|
@ -16,7 +16,7 @@ pub enum Relation {
|
|||||||
from = "Column::BillId",
|
from = "Column::BillId",
|
||||||
to = "super::bills::Column::Id",
|
to = "super::bills::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Bills,
|
Bills,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
@ -24,7 +24,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ pub enum Relation {
|
|||||||
from = "Column::BillId",
|
from = "Column::BillId",
|
||||||
to = "super::bills::Column::Id",
|
to = "super::bills::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Bills,
|
Bills,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
@ -25,7 +25,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub user_id: Option<i32> ,
|
pub user_id: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
@ -15,7 +15,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "NoAction",
|
on_update = "NoAction",
|
||||||
on_delete = "NoAction",
|
on_delete = "NoAction"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
#[sea_orm(has_many = "super::users_votes::Entity")]
|
#[sea_orm(has_many = "super::users_votes::Entity")]
|
||||||
|
@ -17,7 +17,7 @@ pub enum Relation {
|
|||||||
from = "Column::BillId",
|
from = "Column::BillId",
|
||||||
to = "super::bills::Column::Id",
|
to = "super::bills::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Bills,
|
Bills,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
@ -25,7 +25,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "Cascade",
|
on_update = "Cascade",
|
||||||
on_delete = "Cascade",
|
on_delete = "Cascade"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub user_id: Option<i32> ,
|
pub user_id: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
@ -15,7 +15,7 @@ pub enum Relation {
|
|||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id",
|
||||||
on_update = "NoAction",
|
on_update = "NoAction",
|
||||||
on_delete = "NoAction",
|
on_delete = "NoAction"
|
||||||
)]
|
)]
|
||||||
Users,
|
Users,
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ pub struct Model {
|
|||||||
pub user_id: i32,
|
pub user_id: i32,
|
||||||
#[sea_orm(primary_key, auto_increment = false)]
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
pub bill_id: i32,
|
pub bill_id: i32,
|
||||||
pub user_idd: Option<i32> ,
|
pub user_idd: Option<i32>,
|
||||||
pub bill_idd: Option<i32> ,
|
pub bill_idd: Option<i32>,
|
||||||
pub vote: bool,
|
pub vote: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,25 +17,25 @@ pub enum Relation {
|
|||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::bills::Entity",
|
belongs_to = "super::bills::Entity",
|
||||||
from = "Column::BillIdd",
|
from = "Column::BillIdd",
|
||||||
to = "super::bills::Column::Id",
|
to = "super::bills::Column::Id"
|
||||||
)]
|
)]
|
||||||
Bills2,
|
Bills2,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::bills::Entity",
|
belongs_to = "super::bills::Entity",
|
||||||
from = "Column::BillId",
|
from = "Column::BillId",
|
||||||
to = "super::bills::Column::Id",
|
to = "super::bills::Column::Id"
|
||||||
)]
|
)]
|
||||||
Bills1,
|
Bills1,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::users::Entity",
|
belongs_to = "super::users::Entity",
|
||||||
from = "Column::UserIdd",
|
from = "Column::UserIdd",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id"
|
||||||
)]
|
)]
|
||||||
Users2,
|
Users2,
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::users::Entity",
|
belongs_to = "super::users::Entity",
|
||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
to = "super::users::Column::Id",
|
to = "super::users::Column::Id"
|
||||||
)]
|
)]
|
||||||
Users1,
|
Users1,
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,12 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub self_id: Option<i32> ,
|
pub self_id: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
#[sea_orm(
|
#[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")]
|
||||||
belongs_to = "Entity",
|
|
||||||
from = "Column::SelfId",
|
|
||||||
to = "Column::Id",
|
|
||||||
)]
|
|
||||||
SelfRef,
|
SelfRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,23 +5,15 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub self_id: Option<i32> ,
|
pub self_id: Option<i32>,
|
||||||
pub self_idd: Option<i32> ,
|
pub self_idd: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
#[sea_orm(
|
#[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")]
|
||||||
belongs_to = "Entity",
|
|
||||||
from = "Column::SelfId",
|
|
||||||
to = "Column::Id",
|
|
||||||
)]
|
|
||||||
SelfRef2,
|
SelfRef2,
|
||||||
#[sea_orm(
|
#[sea_orm(belongs_to = "Entity", from = "Column::SelfIdd", to = "Column::Id")]
|
||||||
belongs_to = "Entity",
|
|
||||||
from = "Column::SelfIdd",
|
|
||||||
to = "Column::Id",
|
|
||||||
)]
|
|
||||||
SelfRef1,
|
SelfRef1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,15 +37,7 @@ pub async fn test(db: &DbConn) {
|
|||||||
|
|
||||||
assert!(matches!(res, TryInsertResult::Inserted(_)));
|
assert!(matches!(res, TryInsertResult::Inserted(_)));
|
||||||
|
|
||||||
let empty_iterator = [bakery::ActiveModel {
|
let empty_insert = Bakery::insert_many(std::iter::empty())
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
|
||||||
profit_margin: Set(10.4),
|
|
||||||
..Default::default()
|
|
||||||
}]
|
|
||||||
.into_iter()
|
|
||||||
.filter(|_| false);
|
|
||||||
|
|
||||||
let empty_insert = Bakery::insert_many(empty_iterator)
|
|
||||||
.on_empty_do_nothing()
|
.on_empty_do_nothing()
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await;
|
.await;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user