MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / test_reset_2

Function test_reset_2

src/entity/active_model.rs:1459–1523  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1457
1458 #[smol_potat::test]
1459 async fn test_reset_2() -> Result<(), DbErr> {
1460 use crate::*;
1461
1462 let db = MockDatabase::new(DbBackend::Postgres)
1463 .append_exec_results(vec![
1464 MockExecResult {
1465 last_insert_id: 1,
1466 rows_affected: 1,
1467 },
1468 MockExecResult {
1469 last_insert_id: 1,
1470 rows_affected: 1,
1471 },
1472 ])
1473 .append_query_results(vec![
1474 vec![fruit::Model {
1475 id: 1,
1476 name: "Apple".to_owned(),
1477 cake_id: None,
1478 }],
1479 vec![fruit::Model {
1480 id: 1,
1481 name: "Apple".to_owned(),
1482 cake_id: None,
1483 }],
1484 ])
1485 .into_connection();
1486
1487 fruit::Model {
1488 id: 1,
1489 name: "Apple".into(),
1490 cake_id: None,
1491 }
1492 .into_active_model()
1493 .update(&db)
1494 .await?;
1495
1496 fruit::Model {
1497 id: 1,
1498 name: "Apple".into(),
1499 cake_id: None,
1500 }
1501 .into_active_model()
1502 .reset_all()
1503 .update(&db)
1504 .await?;
1505
1506 assert_eq!(
1507 db.into_transaction_log(),
1508 vec![
1509 Transaction::from_sql_and_values(
1510 DbBackend::Postgres,
1511 r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id" FROM "fruit" WHERE "fruit"."id" = $1 LIMIT $2"#,
1512 vec![1i32.into(), 1u64.into()],
1513 ),
1514 Transaction::from_sql_and_values(
1515 DbBackend::Postgres,
1516 r#"UPDATE "fruit" SET "name" = $1, "cake_id" = $2 WHERE "fruit"."id" = $3 RETURNING "id", "name", "cake_id""#,

Callers

nothing calls this directly

Calls 7

into_connectionMethod · 0.80
append_query_resultsMethod · 0.80
append_exec_resultsMethod · 0.80
into_active_modelMethod · 0.80
reset_allMethod · 0.80
newFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected