Skip to content

Commit

Permalink
Revert "Fix CI."
Browse files Browse the repository at this point in the history
This reverts commit 2495b40.
  • Loading branch information
langyo committed Oct 17, 2024
1 parent 3356023 commit e5a7246
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 165 deletions.
12 changes: 3 additions & 9 deletions examples/basic/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ pub async fn insert_and_update(db: &DbConn) -> Result<(), DbErr> {
};
let res = Fruit::insert(pear).exec(db).await?;

println!(
"Inserted: last_insert_id = {}",
res.last_insert_id.ok_or(DbErr::UnpackInsertId)?
);

let pear: Option<fruit::Model> =
Fruit::find_by_id(res.last_insert_id.ok_or(DbErr::UnpackInsertId)?)
.one(db)
.await?;
println!("Inserted: last_insert_id = {}", res.last_insert_id);

let pear: Option<fruit::Model> = Fruit::find_by_id(res.last_insert_id).one(db).await?;

println!("Pear: {pear:?}");

Expand Down
2 changes: 1 addition & 1 deletion examples/graphql_example/service/src/mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Mutation {
let res = Note::insert(active_model).exec(db).await?;

Ok(note::Model {
id: res.last_insert_id.ok_or(DbErr::UnpackInsertId)?,
id: res.last_insert_id,
..form_data
})
}
Expand Down
2 changes: 1 addition & 1 deletion examples/proxy_gluesql_example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl ProxyDatabaseTrait for ProxyDb {
});

Ok(ProxyExecResult {
last_insert_id: Some(1),
last_insert_id: 1,
rows_affected: 1,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,30 @@ impl MigrationTrait for Migration {
profit_margin: Set(10.4),
..Default::default()
};
let sea = Bakery::insert(bakery)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let sea = Bakery::insert(bakery).exec(db).await?.last_insert_id;

let bakery = bakery::ActiveModel {
name: Set("LakeSide Bakery".to_owned()),
profit_margin: Set(5.8),
..Default::default()
};
let lake = Bakery::insert(bakery)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let lake = Bakery::insert(bakery).exec(db).await?.last_insert_id;

let alice = baker::ActiveModel {
name: Set("Alice".to_owned()),
contact: Set("+44 15273388".to_owned()),
bakery_id: Set(Some(sea)),
..Default::default()
};
let alice = Baker::insert(alice)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let alice = Baker::insert(alice).exec(db).await?.last_insert_id;

let bob = baker::ActiveModel {
name: Set("Bob".to_owned()),
contact: Set("+852 12345678".to_owned()),
bakery_id: Set(Some(lake)),
..Default::default()
};
let bob = Baker::insert(bob)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let bob = Baker::insert(bob).exec(db).await?.last_insert_id;

let cake = cake::ActiveModel {
name: Set("Chocolate Cake".to_owned()),
Expand All @@ -63,11 +47,7 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let choco = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let choco = Cake::insert(cake).exec(db).await?.last_insert_id;

let mut cake = cake::ActiveModel {
name: Set("Double Chocolate".to_owned()),
Expand All @@ -76,17 +56,9 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let double_1 = Cake::insert(cake.clone())
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let double_1 = Cake::insert(cake.clone()).exec(db).await?.last_insert_id;
cake.bakery_id = Set(Some(lake));
let double_2 = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let double_2 = Cake::insert(cake).exec(db).await?.last_insert_id;

let mut cake = cake::ActiveModel {
name: Set("Lemon Cake".to_owned()),
Expand All @@ -95,17 +67,9 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let lemon_1 = Cake::insert(cake.clone())
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let lemon_1 = Cake::insert(cake.clone()).exec(db).await?.last_insert_id;
cake.bakery_id = Set(Some(lake));
let lemon_2 = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let lemon_2 = Cake::insert(cake).exec(db).await?.last_insert_id;

let mut cake = cake::ActiveModel {
name: Set("Strawberry Cake".to_owned()),
Expand All @@ -114,17 +78,9 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let straw_1 = Cake::insert(cake.clone())
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let straw_1 = Cake::insert(cake.clone()).exec(db).await?.last_insert_id;
cake.bakery_id = Set(Some(lake));
let straw_2 = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let straw_2 = Cake::insert(cake).exec(db).await?.last_insert_id;

let cake = cake::ActiveModel {
name: Set("Orange Cake".to_owned()),
Expand All @@ -133,11 +89,7 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(lake)),
..Default::default()
};
let orange = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let orange = Cake::insert(cake).exec(db).await?.last_insert_id;

let mut cake = cake::ActiveModel {
name: Set("New York Cheese".to_owned()),
Expand All @@ -146,17 +98,9 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let cheese_1 = Cake::insert(cake.clone())
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let cheese_1 = Cake::insert(cake.clone()).exec(db).await?.last_insert_id;
cake.bakery_id = Set(Some(lake));
let cheese_2 = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let cheese_2 = Cake::insert(cake).exec(db).await?.last_insert_id;

let mut cake = cake::ActiveModel {
name: Set("Blueburry Cheese".to_owned()),
Expand All @@ -165,17 +109,9 @@ impl MigrationTrait for Migration {
bakery_id: Set(Some(sea)),
..Default::default()
};
let blue_1 = Cake::insert(cake.clone())
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let blue_1 = Cake::insert(cake.clone()).exec(db).await?.last_insert_id;
cake.bakery_id = Set(Some(lake));
let blue_2 = Cake::insert(cake)
.exec(db)
.await?
.last_insert_id
.ok_or(DbErr::UnpackInsertId)?;
let blue_2 = Cake::insert(cake).exec(db).await?.last_insert_id;

let rel = cake_baker::ActiveModel {
cake_id: Set(choco),
Expand Down
4 changes: 2 additions & 2 deletions issues/1357/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<()> {
.await?;

assert_eq!(Entity::find().one(&db).await?, Some(model.clone()));
assert_eq!(res.last_insert_id, Some(model.id));
assert_eq!(res.last_insert_id, model.id);

let model = Model {
id: -10,
Expand All @@ -36,7 +36,7 @@ async fn main() -> Result<()> {
.await?;

assert_eq!(Entity::find().one(&db).await?, Some(model.clone()));
assert_eq!(res.last_insert_id, Some(model.id));
assert_eq!(res.last_insert_id, model.id);

Ok(())
}
Loading

0 comments on commit e5a7246

Please sign in to comment.