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

Function active_enum_find_linked

tests/active_enum_tests.rs:759–843  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

757
758 #[test]
759 fn active_enum_find_linked() {
760 let active_enum_model = active_enum::Model {
761 id: 1,
762 category: None,
763 color: None,
764 tea: None,
765 };
766 let _select = active_enum_model.find_linked(active_enum::ActiveEnumChildLink);
767 #[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
768 {
769 assert_eq!(
770 _select.build(DbBackend::Sqlite).to_string(),
771 [
772 r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", "active_enum_child"."tea""#,
773 r#"FROM "active_enum_child""#,
774 r#"INNER JOIN "active_enum" AS "r0" ON "r0"."id" = "active_enum_child"."parent_id""#,
775 r#"WHERE "r0"."id" = 1"#,
776 ]
777 .join(" ")
778 );
779 assert_eq!(
780 _select.build(DbBackend::MySql).to_string(),
781 [
782 "SELECT `active_enum_child`.`id`, `active_enum_child`.`parent_id`, `active_enum_child`.`category`, `active_enum_child`.`color`, `active_enum_child`.`tea`",
783 "FROM `active_enum_child`",
784 "INNER JOIN `active_enum` AS `r0` ON `r0`.`id` = `active_enum_child`.`parent_id`",
785 "WHERE `r0`.`id` = 1",
786 ]
787 .join(" ")
788 );
789 }
790 #[cfg(feature = "sqlx-postgres")]
791 assert_eq!(
792 _select.build(DbBackend::Postgres).to_string(),
793 [
794 r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", CAST("active_enum_child"."tea" AS "text")"#,
795 r#"FROM "public"."active_enum_child""#,
796 r#"INNER JOIN "public"."active_enum" AS "r0" ON "r0"."id" = "active_enum_child"."parent_id""#,
797 r#"WHERE "r0"."id" = 1"#,
798 ]
799 .join(" ")
800 );
801
802 let _select = ActiveEnumEntity::find().find_also_linked(active_enum::ActiveEnumChildLink);
803 #[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
804 {
805 assert_eq!(
806 _select
807 .build(DbBackend::Sqlite)
808 .to_string(),
809 [
810 r#"SELECT "active_enum"."id" AS "A_id", "active_enum"."category" AS "A_category", "active_enum"."color" AS "A_color", "active_enum"."tea" AS "A_tea","#,
811 r#""r0"."id" AS "B_id", "r0"."parent_id" AS "B_parent_id", "r0"."category" AS "B_category", "r0"."color" AS "B_color", "r0"."tea" AS "B_tea""#,
812 r#"FROM "active_enum""#,
813 r#"LEFT JOIN "active_enum_child" AS "r0" ON "active_enum"."id" = "r0"."parent_id""#,
814 ]
815 .join(" ")
816 );

Callers

nothing calls this directly

Calls 2

find_also_linkedMethod · 0.80
find_linkedMethod · 0.45

Tested by

no test coverage detected