| 411 | } |
| 412 | |
| 413 | pub async fn find_related_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> { |
| 414 | assert_eq!( |
| 415 | active_enum::Model { |
| 416 | id: 2, |
| 417 | category: None, |
| 418 | color: None, |
| 419 | tea: None, |
| 420 | } |
| 421 | .find_related(ActiveEnumChild) |
| 422 | .all(db) |
| 423 | .await?, |
| 424 | [active_enum_child::Model { |
| 425 | id: 1, |
| 426 | parent_id: 2, |
| 427 | category: Some(Category::Big), |
| 428 | color: Some(Color::Black), |
| 429 | tea: Some(Tea::EverydayTea), |
| 430 | }] |
| 431 | ); |
| 432 | assert_eq!( |
| 433 | ActiveEnumEntity::find() |
| 434 | .find_with_related(ActiveEnumChild) |
| 435 | .all(db) |
| 436 | .await?, |
| 437 | [( |
| 438 | active_enum::Model { |
| 439 | id: 2, |
| 440 | category: Some(Category::Small), |
| 441 | color: Some(Color::White), |
| 442 | tea: Some(Tea::BreakfastTea), |
| 443 | }, |
| 444 | vec![active_enum_child::Model { |
| 445 | id: 1, |
| 446 | parent_id: 2, |
| 447 | category: Some(Category::Big), |
| 448 | color: Some(Color::Black), |
| 449 | tea: Some(Tea::EverydayTea), |
| 450 | }] |
| 451 | )] |
| 452 | ); |
| 453 | assert_eq!( |
| 454 | ActiveEnumEntity::find() |
| 455 | .find_also_related(ActiveEnumChild) |
| 456 | .all(db) |
| 457 | .await?, |
| 458 | [( |
| 459 | active_enum::Model { |
| 460 | id: 2, |
| 461 | category: Some(Category::Small), |
| 462 | color: Some(Color::White), |
| 463 | tea: Some(Tea::BreakfastTea), |
| 464 | }, |
| 465 | Some(active_enum_child::Model { |
| 466 | id: 1, |
| 467 | parent_id: 2, |
| 468 | category: Some(Category::Big), |
| 469 | color: Some(Color::Black), |
| 470 | tea: Some(Tea::EverydayTea), |