()
| 240 | |
| 241 | #[sea_orm_macros::test] |
| 242 | async fn partial_model_join_three() { |
| 243 | let ctx = TestContext::new("partial_model_join_three").await; |
| 244 | create_tables(&ctx.db).await.unwrap(); |
| 245 | |
| 246 | seed_data::init_1(&ctx, true).await; |
| 247 | |
| 248 | #[derive(Debug, DerivePartialModel, PartialEq)] |
| 249 | #[sea_orm(entity = "order::Entity", from_query_result)] |
| 250 | struct OrderItem { |
| 251 | id: i32, |
| 252 | total: Decimal, |
| 253 | #[sea_orm(nested)] |
| 254 | customer: Customer, |
| 255 | #[sea_orm(nested)] |
| 256 | line: LineItem, |
| 257 | } |
| 258 | |
| 259 | #[derive(Debug, DerivePartialModel, PartialEq)] |
| 260 | #[sea_orm(entity = "customer::Entity", from_query_result)] |
| 261 | struct Customer { |
| 262 | name: String, |
| 263 | } |
| 264 | |
| 265 | #[derive(Debug, DerivePartialModel, PartialEq)] |
| 266 | #[sea_orm(entity = "lineitem::Entity", from_query_result)] |
| 267 | struct LineItem { |
| 268 | price: Decimal, |
| 269 | quantity: i32, |
| 270 | #[sea_orm(nested)] |
| 271 | cake: Cake, |
| 272 | } |
| 273 | |
| 274 | #[derive(Debug, DerivePartialModel, PartialEq)] |
| 275 | #[sea_orm(entity = "cake::Entity", from_query_result)] |
| 276 | struct Cake { |
| 277 | name: String, |
| 278 | } |
| 279 | |
| 280 | let items: Vec<OrderItem> = order::Entity::find() |
| 281 | .left_join(customer::Entity) |
| 282 | .left_join(lineitem::Entity) |
| 283 | .join(JoinType::LeftJoin, lineitem::Relation::Cake.def()) |
| 284 | .order_by_asc(order::Column::Id) |
| 285 | .order_by_asc(lineitem::Column::Id) |
| 286 | .into_partial_model() |
| 287 | .all(&ctx.db) |
| 288 | .await |
| 289 | .unwrap(); |
| 290 | |
| 291 | assert_eq!( |
| 292 | items, |
| 293 | [ |
| 294 | OrderItem { |
| 295 | id: 101, |
| 296 | total: Decimal::from(10), |
| 297 | customer: Customer { |
| 298 | name: "Bob".to_owned() |
| 299 | }, |
nothing calls this directly
no test coverage detected