()
| 114 | |
| 115 | #[sea_orm_macros::test] |
| 116 | async fn loader_load_many_multi() -> Result<(), DbErr> { |
| 117 | let ctx = TestContext::new("loader_test_load_many_multi").await; |
| 118 | create_tables(&ctx.db).await?; |
| 119 | |
| 120 | let bakery_1 = insert_bakery(&ctx.db, "SeaSide Bakery").await?; |
| 121 | let bakery_2 = insert_bakery(&ctx.db, "Offshore Bakery").await?; |
| 122 | |
| 123 | let baker_1 = insert_baker(&ctx.db, "John", bakery_1.id).await?; |
| 124 | let baker_2 = insert_baker(&ctx.db, "Jane", bakery_1.id).await?; |
| 125 | let baker_3 = insert_baker(&ctx.db, "Peter", bakery_2.id).await?; |
| 126 | |
| 127 | let cake_1 = insert_cake(&ctx.db, "Cheesecake", Some(bakery_1.id)).await?; |
| 128 | let cake_2 = insert_cake(&ctx.db, "Chocolate", Some(bakery_2.id)).await?; |
| 129 | let cake_3 = insert_cake(&ctx.db, "Chiffon", Some(bakery_2.id)).await?; |
| 130 | let _cake_4 = insert_cake(&ctx.db, "Apple Pie", None).await?; // no one makes apple pie |
| 131 | |
| 132 | let bakeries = bakery::Entity::find().all(&ctx.db).await?; |
| 133 | let bakers = bakeries.load_many(baker::Entity, &ctx.db).await?; |
| 134 | let cakes = bakeries.load_many(cake::Entity, &ctx.db).await?; |
| 135 | |
| 136 | assert_eq!(bakeries, [bakery_1, bakery_2]); |
| 137 | assert_eq!(bakers, [vec![baker_1, baker_2], vec![baker_3]]); |
| 138 | assert_eq!(cakes, [vec![cake_1], vec![cake_2, cake_3]]); |
| 139 | |
| 140 | Ok(()) |
| 141 | } |
| 142 | |
| 143 | #[sea_orm_macros::test] |
| 144 | async fn loader_load_many_to_many() -> Result<(), DbErr> { |
nothing calls this directly
no test coverage detected