diff --git a/tests/crud/mod.rs b/tests/crud/mod.rs index ebf15499..653328ab 100644 --- a/tests/crud/mod.rs +++ b/tests/crud/mod.rs @@ -1,8 +1,8 @@ -use sea_orm::{entity::*, DbConn, ExecErr, InsertResult}; +use sea_orm::{entity::*, error::*, DbConn, InsertResult}; pub use super::bakery_chain::*; -pub async fn create_bakery(db: &DbConn) -> Result<(), ExecErr> { +pub async fn create_bakery(db: &DbConn) -> Result<(), DbErr> { let seaside_bakery = bakery::ActiveModel { name: Set("SeaSide Bakery".to_owned()), profit_margin: Set(10.4), @@ -10,10 +10,7 @@ pub async fn create_bakery(db: &DbConn) -> Result<(), ExecErr> { }; let res: InsertResult = Bakery::insert(seaside_bakery).exec(db).await?; - let bakery: Option = Bakery::find_by_id(res.last_insert_id) - .one(db) - .await - .map_err(|_| ExecErr)?; + let bakery: Option = Bakery::find_by_id(res.last_insert_id).one(db).await?; assert!(bakery.is_some()); let bakery_model = bakery.unwrap(); diff --git a/tests/schema/mod.rs b/tests/schema/mod.rs index d9d249e3..2841066c 100644 --- a/tests/schema/mod.rs +++ b/tests/schema/mod.rs @@ -1,14 +1,14 @@ -use sea_orm::{sea_query, DbConn, ExecErr, ExecResult}; +use sea_orm::{error::*, sea_query, DbConn, ExecResult}; use sea_query::{ColumnDef, ForeignKey, ForeignKeyAction, Index, TableCreateStatement}; pub use super::bakery_chain::*; -async fn create_table(db: &DbConn, stmt: &TableCreateStatement) -> Result { +async fn create_table(db: &DbConn, stmt: &TableCreateStatement) -> Result { let builder = db.get_schema_builder_backend(); db.execute(builder.build(stmt)).await } -pub async fn create_bakery_table(db: &DbConn) -> Result { +pub async fn create_bakery_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(bakery::Entity) .if_not_exists() @@ -26,7 +26,7 @@ pub async fn create_bakery_table(db: &DbConn) -> Result { create_table(db, &stmt).await } -pub async fn create_baker_table(db: &DbConn) -> Result { +pub async fn create_baker_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(baker::Entity) .if_not_exists() @@ -52,7 +52,7 @@ pub async fn create_baker_table(db: &DbConn) -> Result { create_table(db, &stmt).await } -pub async fn create_customer_table(db: &DbConn) -> Result { +pub async fn create_customer_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(customer::Entity) .if_not_exists() @@ -70,7 +70,7 @@ pub async fn create_customer_table(db: &DbConn) -> Result { create_table(db, &stmt).await } -pub async fn create_order_table(db: &DbConn) -> Result { +pub async fn create_order_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(order::Entity) .if_not_exists() @@ -114,7 +114,7 @@ pub async fn create_order_table(db: &DbConn) -> Result { create_table(db, &stmt).await } -pub async fn create_lineitem_table(db: &DbConn) -> Result { +pub async fn create_lineitem_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(lineitem::Entity) .if_not_exists() @@ -145,7 +145,7 @@ pub async fn create_lineitem_table(db: &DbConn) -> Result { create_table(db, &stmt).await } -pub async fn create_cakes_bakers_table(db: &DbConn) -> Result { +pub async fn create_cakes_bakers_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(cakes_bakers::Entity) .if_not_exists() @@ -169,7 +169,7 @@ pub async fn create_cakes_bakers_table(db: &DbConn) -> Result Result { +pub async fn create_cake_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() .table(cake::Entity) .if_not_exists()