()
| 201 | |
| 202 | #[sea_orm_macros::test] |
| 203 | pub async fn inner_join() { |
| 204 | let ctx = TestContext::new("test_inner_join").await; |
| 205 | create_tables(&ctx.db).await.unwrap(); |
| 206 | |
| 207 | let bakery = bakery::ActiveModel { |
| 208 | name: Set("SeaSide Bakery".to_owned()), |
| 209 | profit_margin: Set(10.4), |
| 210 | ..Default::default() |
| 211 | } |
| 212 | .insert(&ctx.db) |
| 213 | .await |
| 214 | .expect("could not insert bakery"); |
| 215 | |
| 216 | let customer_kate = customer::ActiveModel { |
| 217 | name: Set("Kate".to_owned()), |
| 218 | ..Default::default() |
| 219 | } |
| 220 | .insert(&ctx.db) |
| 221 | .await |
| 222 | .expect("could not insert customer"); |
| 223 | |
| 224 | let _customer_jim = customer::ActiveModel { |
| 225 | name: Set("Jim".to_owned()), |
| 226 | ..Default::default() |
| 227 | } |
| 228 | .insert(&ctx.db) |
| 229 | .await |
| 230 | .expect("could not insert customer"); |
| 231 | |
| 232 | let kate_order_1 = order::ActiveModel { |
| 233 | bakery_id: Set(bakery.id), |
| 234 | customer_id: Set(customer_kate.id), |
| 235 | total: Set(rust_dec(15.10)), |
| 236 | placed_at: Set(Utc::now().naive_utc()), |
| 237 | |
| 238 | ..Default::default() |
| 239 | } |
| 240 | .insert(&ctx.db) |
| 241 | .await |
| 242 | .expect("could not insert order"); |
| 243 | |
| 244 | let kate_order_2 = order::ActiveModel { |
| 245 | bakery_id: Set(bakery.id), |
| 246 | customer_id: Set(customer_kate.id), |
| 247 | total: Set(rust_dec(100.00)), |
| 248 | placed_at: Set(Utc::now().naive_utc()), |
| 249 | |
| 250 | ..Default::default() |
| 251 | } |
| 252 | .insert(&ctx.db) |
| 253 | .await |
| 254 | .expect("could not insert order"); |
| 255 | |
| 256 | #[derive(Debug, FromQueryResult)] |
| 257 | struct SelectResult { |
| 258 | name: String, |
| 259 | order_total: Option<Decimal>, |
| 260 | } |
nothing calls this directly
no test coverage detected