diff --git a/src/executor/select.rs b/src/executor/select.rs index be4c2354..2997448a 100644 --- a/src/executor/select.rs +++ b/src/executor/select.rs @@ -266,11 +266,22 @@ where /// # #[cfg(feature = "mock")] /// # use sea_orm::{error::*, tests_cfg::*, MockDatabase, Transaction, DbBackend}; /// # - /// # let db = MockDatabase::new(DbBackend::Postgres).into_connection(); + /// # let db = MockDatabase::new(DbBackend::Postgres) + /// # .append_query_results(vec![vec![ + /// # maplit::btreemap! { + /// # "name" => Into::::into("Chocolate Forest"), + /// # "num_of_cakes" => Into::::into(1), + /// # }, + /// # maplit::btreemap! { + /// # "name" => Into::::into("New York Cheese"), + /// # "num_of_cakes" => Into::::into(1), + /// # }, + /// # ]]) + /// # .into_connection(); /// # /// use sea_orm::{entity::*, query::*, tests_cfg::cake, FromQueryResult}; /// - /// #[derive(Debug, FromQueryResult)] + /// #[derive(Debug, PartialEq, FromQueryResult)] /// struct SelectResult { /// name: String, /// num_of_cakes: i32, @@ -278,7 +289,7 @@ where /// /// # let _: Result<(), DbErr> = async_std::task::block_on(async { /// # - /// let _: Vec = cake::Entity::find().from_raw_sql( + /// let res: Vec = cake::Entity::find().from_raw_sql( /// Statement::from_sql_and_values( /// DbBackend::Postgres, r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#, vec![] /// ) @@ -286,6 +297,20 @@ where /// .into_model::() /// .all(&db) /// .await?; + /// + /// assert_eq!( + /// res, + /// vec![ + /// SelectResult { + /// name: "Chocolate Forest".to_owned(), + /// num_of_cakes: 1, + /// }, + /// SelectResult { + /// name: "New York Cheese".to_owned(), + /// num_of_cakes: 1, + /// }, + /// ] + /// ); /// # /// # Ok(()) /// # }); @@ -312,13 +337,24 @@ where /// # #[cfg(feature = "mock")] /// # use sea_orm::{error::*, tests_cfg::*, MockDatabase, Transaction, DbBackend}; /// # - /// # let db = MockDatabase::new(DbBackend::Postgres).into_connection(); + /// # let db = MockDatabase::new(DbBackend::Postgres) + /// # .append_query_results(vec![vec![ + /// # maplit::btreemap! { + /// # "name" => Into::::into("Chocolate Forest"), + /// # "num_of_cakes" => Into::::into(1), + /// # }, + /// # maplit::btreemap! { + /// # "name" => Into::::into("New York Cheese"), + /// # "num_of_cakes" => Into::::into(1), + /// # }, + /// # ]]) + /// # .into_connection(); /// # /// use sea_orm::{entity::*, query::*, tests_cfg::cake}; /// /// # let _: Result<(), DbErr> = async_std::task::block_on(async { /// # - /// let _: Vec = cake::Entity::find().from_raw_sql( + /// let res: Vec = cake::Entity::find().from_raw_sql( /// Statement::from_sql_and_values( /// DbBackend::Postgres, r#"SELECT "cake"."id", "cake"."name" FROM "cake""#, vec![] /// ) @@ -326,6 +362,20 @@ where /// .into_json() /// .all(&db) /// .await?; + /// + /// assert_eq!( + /// res, + /// vec![ + /// serde_json::json!({ + /// "name": "Chocolate Forest", + /// "num_of_cakes": 1, + /// }), + /// serde_json::json!({ + /// "name": "New York Cheese", + /// "num_of_cakes": 1, + /// }), + /// ] + /// ); /// # /// # Ok(()) /// # });