diff --git a/src/executor/update.rs b/src/executor/update.rs index b7277ccd..0cd42903 100644 --- a/src/executor/update.rs +++ b/src/executor/update.rs @@ -159,10 +159,15 @@ mod tests { #[smol_potat::test] async fn update_record_not_found_1() -> Result<(), DbErr> { let db = MockDatabase::new(DbBackend::Postgres) - .append_query_results(vec![vec![cake::Model { - id: 1, - name: "Cheese Cake".to_owned(), - }]]) + .append_query_results(vec![ + vec![cake::Model { + id: 1, + name: "Cheese Cake".to_owned(), + }], + vec![], + vec![], + vec![], + ]) .append_exec_results(vec![ MockExecResult { last_insert_id: 0, @@ -211,43 +216,41 @@ mod tests { name: "New York Cheese".to_owned(), }; - // FIXME: Breaking! + assert_eq!( + cake::ActiveModel { + name: Set("Cheese Cake".to_owned()), + ..model.clone().into_active_model() + } + .update(&db) + .await, + Err(DbErr::RecordNotFound( + "None of the database rows are affected".to_owned() + )) + ); - // assert_eq!( - // cake::ActiveModel { - // name: Set("Cheese Cake".to_owned()), - // ..model.clone().into_active_model() - // } - // .update(&db) - // .await, - // Err(DbErr::RecordNotFound( - // "None of the database rows are affected".to_owned() - // )) - // ); + assert_eq!( + cake::Entity::update(cake::ActiveModel { + name: Set("Cheese Cake".to_owned()), + ..model.clone().into_active_model() + }) + .exec(&db) + .await, + Err(DbErr::RecordNotFound( + "None of the database rows are affected".to_owned() + )) + ); - // assert_eq!( - // cake::Entity::update(cake::ActiveModel { - // name: Set("Cheese Cake".to_owned()), - // ..model.clone().into_active_model() - // }) - // .exec(&db) - // .await, - // Err(DbErr::RecordNotFound( - // "None of the database rows are affected".to_owned() - // )) - // ); - - // assert_eq!( - // Update::one(cake::ActiveModel { - // name: Set("Cheese Cake".to_owned()), - // ..model.into_active_model() - // }) - // .exec(&db) - // .await, - // Err(DbErr::RecordNotFound( - // "None of the database rows are affected".to_owned() - // )) - // ); + assert_eq!( + Update::one(cake::ActiveModel { + name: Set("Cheese Cake".to_owned()), + ..model.into_active_model() + }) + .exec(&db) + .await, + Err(DbErr::RecordNotFound( + "None of the database rows are affected".to_owned() + )) + ); assert_eq!( Update::many(cake::Entity) @@ -266,25 +269,21 @@ mod tests { r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2 RETURNING "id", "name""#, vec!["Cheese Cake".into(), 1i32.into()] ), - // FIXME: Breaking! - - // Transaction::from_sql_and_values( - // DbBackend::Postgres, - // r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2"#, - // vec!["Cheese Cake".into(), 2i32.into()] - // ), - - // Transaction::from_sql_and_values( - // DbBackend::Postgres, - // r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2"#, - // vec!["Cheese Cake".into(), 2i32.into()] - // ), - - // Transaction::from_sql_and_values( - // DbBackend::Postgres, - // r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2"#, - // vec!["Cheese Cake".into(), 2i32.into()] - // ), + Transaction::from_sql_and_values( + DbBackend::Postgres, + r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2 RETURNING "id", "name""#, + vec!["Cheese Cake".into(), 2i32.into()] + ), + Transaction::from_sql_and_values( + DbBackend::Postgres, + r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2 RETURNING "id", "name""#, + vec!["Cheese Cake".into(), 2i32.into()] + ), + Transaction::from_sql_and_values( + DbBackend::Postgres, + r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2 RETURNING "id", "name""#, + vec!["Cheese Cake".into(), 2i32.into()] + ), Transaction::from_sql_and_values( DbBackend::Postgres, r#"UPDATE "cake" SET "name" = $1 WHERE "cake"."id" = $2"#,