WIP
This commit is contained in:
parent
ccfda51a5e
commit
3bada7fbc3
@ -87,7 +87,7 @@ let pear = fruit::ActiveModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// insert one
|
// insert one
|
||||||
let res: InsertResult = Fruit::insert(pear).exec(db).await?;
|
let res = Fruit::insert(pear).exec(db).await?;
|
||||||
|
|
||||||
println!("InsertResult: {}", res.last_insert_id);
|
println!("InsertResult: {}", res.last_insert_id);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ pub async fn insert_and_update(db: &DbConn) -> Result<(), DbErr> {
|
|||||||
name: Set("pear".to_owned()),
|
name: Set("pear".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let res: InsertResult = Fruit::insert(pear).exec(db).await?;
|
let res = Fruit::insert(pear).exec(db).await?;
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
println!("Inserted: last_insert_id = {}\n", res.last_insert_id);
|
println!("Inserted: last_insert_id = {}\n", res.last_insert_id);
|
||||||
|
@ -102,24 +102,18 @@ impl From<PgRow> for QueryResult {
|
|||||||
impl From<PgQueryResult> for ExecResult {
|
impl From<PgQueryResult> for ExecResult {
|
||||||
fn from(result: PgQueryResult) -> ExecResult {
|
fn from(result: PgQueryResult) -> ExecResult {
|
||||||
ExecResult {
|
ExecResult {
|
||||||
result: ExecResultHolder::SqlxPostgres {
|
result: ExecResultHolder::SqlxPostgres(result),
|
||||||
last_insert_id: 0,
|
|
||||||
rows_affected: result.rows_affected(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn query_result_into_exec_result<T>(res: QueryResult) -> Result<ExecResult, DbErr>
|
pub(crate) fn query_result_into_exec_result(res: QueryResult) -> Result<ExecResult, DbErr> {
|
||||||
where
|
let result = match res {
|
||||||
T: TryGetable,
|
QueryResult::SqlxPostgres(result) => result,
|
||||||
{
|
_ => panic!("Should be QueryResult::SqlxPostgres"),
|
||||||
let last_insert_id: T = res.try_get("", "last_insert_id")?;
|
};
|
||||||
Ok(ExecResult {
|
Ok(ExecResult {
|
||||||
result: ExecResultHolder::SqlxPostgres {
|
result: ExecResultHolder::SqlxPostgres(result),
|
||||||
last_insert_id: last_insert_id as u64,
|
|
||||||
rows_affected: 0,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use crate::TryGetable;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ExecResult {
|
pub struct ExecResult {
|
||||||
pub(crate) result: ExecResultHolder,
|
pub(crate) result: ExecResultHolder,
|
||||||
@ -8,10 +10,7 @@ pub(crate) enum ExecResultHolder {
|
|||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
SqlxMySql(sqlx::mysql::MySqlQueryResult),
|
SqlxMySql(sqlx::mysql::MySqlQueryResult),
|
||||||
#[cfg(feature = "sqlx-postgres")]
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
SqlxPostgres {
|
SqlxPostgres(sqlx::postgres::PgQueryResult),
|
||||||
last_insert_id: u64,
|
|
||||||
rows_affected: u64,
|
|
||||||
},
|
|
||||||
#[cfg(feature = "sqlx-sqlite")]
|
#[cfg(feature = "sqlx-sqlite")]
|
||||||
SqlxSqlite(sqlx::sqlite::SqliteQueryResult),
|
SqlxSqlite(sqlx::sqlite::SqliteQueryResult),
|
||||||
#[cfg(feature = "mock")]
|
#[cfg(feature = "mock")]
|
||||||
@ -21,23 +20,35 @@ pub(crate) enum ExecResultHolder {
|
|||||||
// ExecResult //
|
// ExecResult //
|
||||||
|
|
||||||
impl ExecResult {
|
impl ExecResult {
|
||||||
pub fn last_insert_id(&self) -> u64 {
|
pub fn last_insert_id<T>(&self) -> T
|
||||||
|
where
|
||||||
|
T: TryGetable + Default,
|
||||||
|
{
|
||||||
match &self.result {
|
match &self.result {
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
ExecResultHolder::SqlxMySql(result) => result.last_insert_id(),
|
ExecResultHolder::SqlxMySql(result) => {
|
||||||
|
// result.last_insert_id()
|
||||||
|
T::default()
|
||||||
|
}
|
||||||
#[cfg(feature = "sqlx-postgres")]
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
ExecResultHolder::SqlxPostgres { last_insert_id, .. } => last_insert_id.to_owned(),
|
ExecResultHolder::SqlxPostgres(result) => {
|
||||||
|
res.try_get("", "last_insert_id").unwrap_or_default()
|
||||||
|
}
|
||||||
#[cfg(feature = "sqlx-sqlite")]
|
#[cfg(feature = "sqlx-sqlite")]
|
||||||
ExecResultHolder::SqlxSqlite(result) => {
|
ExecResultHolder::SqlxSqlite(result) => {
|
||||||
let last_insert_rowid = result.last_insert_rowid();
|
let last_insert_rowid = result.last_insert_rowid();
|
||||||
if last_insert_rowid < 0 {
|
if last_insert_rowid < 0 {
|
||||||
panic!("negative last_insert_rowid")
|
panic!("negative last_insert_rowid")
|
||||||
} else {
|
} else {
|
||||||
last_insert_rowid as u64
|
// last_insert_rowid
|
||||||
|
T::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "mock")]
|
#[cfg(feature = "mock")]
|
||||||
ExecResultHolder::Mock(result) => result.last_insert_id,
|
ExecResultHolder::Mock(result) => {
|
||||||
|
// result.last_insert_id
|
||||||
|
T::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +57,7 @@ impl ExecResult {
|
|||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
ExecResultHolder::SqlxMySql(result) => result.rows_affected(),
|
ExecResultHolder::SqlxMySql(result) => result.rows_affected(),
|
||||||
#[cfg(feature = "sqlx-postgres")]
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
ExecResultHolder::SqlxPostgres { rows_affected, .. } => rows_affected.to_owned(),
|
ExecResultHolder::SqlxPostgres(result) => result.rows_affected(),
|
||||||
#[cfg(feature = "sqlx-sqlite")]
|
#[cfg(feature = "sqlx-sqlite")]
|
||||||
ExecResultHolder::SqlxSqlite(result) => result.rows_affected(),
|
ExecResultHolder::SqlxSqlite(result) => result.rows_affected(),
|
||||||
#[cfg(feature = "mock")]
|
#[cfg(feature = "mock")]
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! // insert one
|
//! // insert one
|
||||||
//! let res: InsertResult = Fruit::insert(pear).exec(db).await?;
|
//! let res = Fruit::insert(pear).exec(db).await?;
|
||||||
//!
|
//!
|
||||||
//! println!("InsertResult: {}", res.last_insert_id);
|
//! println!("InsertResult: {}", res.last_insert_id);
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
|
@ -7,7 +7,7 @@ pub async fn test_create_baker(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -30,7 +30,7 @@ pub async fn test_create_baker(db: &DbConn) {
|
|||||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let res: InsertResult = Baker::insert(baker_bob)
|
let res = Baker::insert(baker_bob)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert baker");
|
.expect("could not insert baker");
|
||||||
|
@ -8,7 +8,7 @@ pub async fn test_create_cake(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -23,7 +23,7 @@ pub async fn test_create_cake(db: &DbConn) {
|
|||||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let baker_insert_res: InsertResult = Baker::insert(baker_bob)
|
let baker_insert_res = Baker::insert(baker_bob)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert baker");
|
.expect("could not insert baker");
|
||||||
@ -38,7 +38,7 @@ pub async fn test_create_cake(db: &DbConn) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(mud_cake)
|
let cake_insert_res = Cake::insert(mud_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -53,7 +53,7 @@ pub async fn test_create_cake(db: &DbConn) {
|
|||||||
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let _cake_baker_res: InsertResult = CakesBakers::insert(cake_baker)
|
let _cake_baker_res = CakesBakers::insert(cake_baker)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake_baker");
|
.expect("could not insert cake_baker");
|
||||||
|
@ -10,7 +10,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -26,7 +26,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let baker_insert_res: InsertResult = Baker::insert(baker_bob)
|
let baker_insert_res = Baker::insert(baker_bob)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert baker");
|
.expect("could not insert baker");
|
||||||
@ -41,7 +41,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(mud_cake)
|
let cake_insert_res = Cake::insert(mud_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -52,7 +52,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let _cake_baker_res: InsertResult = CakesBakers::insert(cake_baker)
|
let _cake_baker_res = CakesBakers::insert(cake_baker)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake_baker");
|
.expect("could not insert cake_baker");
|
||||||
@ -63,7 +63,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
notes: Set(Some("Loves cheese cake".to_owned())),
|
notes: Set(Some("Loves cheese cake".to_owned())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let customer_insert_res: InsertResult = Customer::insert(customer_kate)
|
let customer_insert_res = Customer::insert(customer_kate)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert customer");
|
.expect("could not insert customer");
|
||||||
@ -76,7 +76,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
placed_at: Set(Utc::now().naive_utc()),
|
placed_at: Set(Utc::now().naive_utc()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
let order_insert_res = Order::insert(order_1)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert order");
|
.expect("could not insert order");
|
||||||
@ -89,7 +89,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
|||||||
quantity: Set(1),
|
quantity: Set(1),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let lineitem_insert_res: InsertResult = Lineitem::insert(lineitem_1)
|
let lineitem_insert_res = Lineitem::insert(lineitem_1)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert lineitem");
|
.expect("could not insert lineitem");
|
||||||
|
@ -10,7 +10,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -26,7 +26,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let baker_insert_res: InsertResult = Baker::insert(baker_bob)
|
let baker_insert_res = Baker::insert(baker_bob)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert baker");
|
.expect("could not insert baker");
|
||||||
@ -41,7 +41,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(mud_cake)
|
let cake_insert_res = Cake::insert(mud_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -52,7 +52,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
baker_id: Set(baker_insert_res.last_insert_id as i32),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let _cake_baker_res: InsertResult = CakesBakers::insert(cake_baker)
|
let _cake_baker_res = CakesBakers::insert(cake_baker)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake_baker");
|
.expect("could not insert cake_baker");
|
||||||
@ -63,7 +63,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
notes: Set(Some("Loves cheese cake".to_owned())),
|
notes: Set(Some("Loves cheese cake".to_owned())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let customer_insert_res: InsertResult = Customer::insert(customer_kate)
|
let customer_insert_res = Customer::insert(customer_kate)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert customer");
|
.expect("could not insert customer");
|
||||||
@ -76,7 +76,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
placed_at: Set(Utc::now().naive_utc()),
|
placed_at: Set(Utc::now().naive_utc()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
let order_insert_res = Order::insert(order_1)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert order");
|
.expect("could not insert order");
|
||||||
@ -89,7 +89,7 @@ pub async fn test_create_order(db: &DbConn) {
|
|||||||
quantity: Set(2),
|
quantity: Set(2),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let _lineitem_insert_res: InsertResult = Lineitem::insert(lineitem_1)
|
let _lineitem_insert_res = Lineitem::insert(lineitem_1)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert lineitem");
|
.expect("could not insert lineitem");
|
||||||
|
@ -10,7 +10,7 @@ pub async fn test_delete_cake(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
|
@ -15,7 +15,7 @@ pub async fn test_create_bakery(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let res: InsertResult = Bakery::insert(seaside_bakery)
|
let res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -37,7 +37,7 @@ pub async fn test_create_customer(db: &DbConn) {
|
|||||||
notes: Set(Some("Loves cheese cake".to_owned())),
|
notes: Set(Some("Loves cheese cake".to_owned())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let res: InsertResult = Customer::insert(customer_kate)
|
let res = Customer::insert(customer_kate)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert customer");
|
.expect("could not insert customer");
|
||||||
|
@ -8,7 +8,7 @@ pub async fn test_update_cake(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
@ -22,7 +22,7 @@ pub async fn test_update_cake(db: &DbConn) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(mud_cake)
|
let cake_insert_res = Cake::insert(mud_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -62,7 +62,7 @@ pub async fn test_update_bakery(db: &DbConn) {
|
|||||||
profit_margin: Set(10.4),
|
profit_margin: Set(10.4),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let bakery_insert_res: InsertResult = Bakery::insert(seaside_bakery)
|
let bakery_insert_res = Bakery::insert(seaside_bakery)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert bakery");
|
.expect("could not insert bakery");
|
||||||
|
@ -67,7 +67,7 @@ async fn init_setup(db: &DatabaseConnection) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(mud_cake)
|
let cake_insert_res = Cake::insert(mud_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -78,7 +78,7 @@ async fn init_setup(db: &DatabaseConnection) {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let _cake_baker_res: InsertResult = CakesBakers::insert(cake_baker)
|
let _cake_baker_res = CakesBakers::insert(cake_baker)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake_baker");
|
.expect("could not insert cake_baker");
|
||||||
@ -200,7 +200,7 @@ async fn create_cake(db: &DatabaseConnection, baker: baker::Model) -> Option<cak
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let cake_insert_res: InsertResult = Cake::insert(new_cake)
|
let cake_insert_res = Cake::insert(new_cake)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake");
|
.expect("could not insert cake");
|
||||||
@ -211,7 +211,7 @@ async fn create_cake(db: &DatabaseConnection, baker: baker::Model) -> Option<cak
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let _cake_baker_res: InsertResult = CakesBakers::insert(cake_baker)
|
let _cake_baker_res = CakesBakers::insert(cake_baker)
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await
|
.await
|
||||||
.expect("could not insert cake_baker");
|
.expect("could not insert cake_baker");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user