diff --git a/src/entity/model.rs b/src/entity/model.rs index ce4a3a4c6..f71c12297 100644 --- a/src/entity/model.rs +++ b/src/entity/model.rs @@ -44,11 +44,7 @@ pub trait FromQueryResult: Sized { /// # .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), + /// # "num_of_cakes" => Into::::into(2), /// # }, /// # ]]) /// # .into_connection(); @@ -65,7 +61,7 @@ pub trait FromQueryResult: Sized { /// # /// let res: Vec = SelectResult::find_by_statement(Statement::from_sql_and_values( /// DbBackend::Postgres, - /// r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#, + /// r#"SELECT "name", COUNT(*) AS "num_of_cakes" FROM "cake" GROUP BY("name")"#, /// vec![], /// )) /// .all(&db) @@ -76,26 +72,21 @@ pub trait FromQueryResult: Sized { /// vec![ /// SelectResult { /// name: "Chocolate Forest".to_owned(), - /// num_of_cakes: 1, - /// }, - /// SelectResult { - /// name: "New York Cheese".to_owned(), - /// num_of_cakes: 1, + /// num_of_cakes: 2, /// }, /// ] /// ); /// # /// # Ok(()) /// # }); - /// - /// assert_eq!( - /// db.into_transaction_log(), - /// vec![Transaction::from_sql_and_values( - /// DbBackend::Postgres, - /// r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#, - /// vec![] - /// ),] - /// ); + /// # assert_eq!( + /// # db.into_transaction_log(), + /// # vec![Transaction::from_sql_and_values( + /// # DbBackend::Postgres, + /// # r#"SELECT "name", COUNT(*) AS "num_of_cakes" FROM "cake" GROUP BY("name")"#, + /// # vec![] + /// # ),] + /// # ); /// ``` fn find_by_statement(stmt: Statement) -> SelectorRaw> { SelectorRaw::>::from_statement(stmt)