Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop SelectTwoMany::one() method #813

Merged
merged 1 commit into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/executor/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,6 @@ where
}
}

/// Select one Model
pub async fn one<'a, C>(self, db: &C) -> Result<Option<(E::Model, Option<F::Model>)>, 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,
Expand All @@ -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<F>)>`
/// and the return value is a pair of models instead of `(E, Vec<F>)`
/// which is a weird query result for a one-to-many relationship.
///
/// Users are advised to query `(E, Vec<F>)` by first querying `E` from the database,
/// then use `find_related` method to query `Vec<F>`.
/// 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<Option<(E::Model, Option<F::Model>)>, 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<Vec<(E::Model, Vec<F::Model>)>, DbErr>
where
Expand Down