From 43c7fe81f1e591e8bc6ea31f02f43c44480f4859 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Wed, 22 Jun 2022 17:29:08 +0800 Subject: [PATCH] Drop `SelectTwoMany::one` method --- src/executor/select.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/executor/select.rs b/src/executor/select.rs index c7be57c21..37c844ab5 100644 --- a/src/executor/select.rs +++ b/src/executor/select.rs @@ -361,14 +361,6 @@ where } } - /// Select one Model - pub async fn one<'a, C>(self, db: &C) -> Result)>, DbErr> - where - C: ConnectionTrait, - { - self.into_model().one(db).await - } - /// Stream the result of the operation pub async fn stream<'a: 'b, 'b, C>( self, @@ -380,6 +372,22 @@ where self.into_model().stream(db).await } + /// `SelectTwoMany::one()` method is being dropped: + /// `SelectTwoMany` is for selecting models of a one-to-many relationship + /// but `SelectTwoMany::one()` returns `Option<(E, Option)>` + /// and the return value is a pair of models instead of `(E, Vec)` + /// which is a weird query result for a one-to-many relationship. + /// + /// Users are advised to query `(E, Vec)` by first querying `E` from the database, + /// then use `find_related` method to query `Vec`. + /// Read https://www.sea-ql.org/SeaORM/docs/basic-crud/select#lazy-loading for details. + // pub async fn one<'a, C>(self, db: &C) -> Result)>, DbErr> + // where + // C: ConnectionTrait, + // { + // self.into_model().one(db).await + // } + /// Get all Models from the select operation pub async fn all<'a, C>(self, db: &C) -> Result)>, DbErr> where