sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

Add `into_tuple` to `SelectTwo` and `SelectTwoMany`

Open miam-miam opened this issue 1 year ago • 2 comments

Motivation

Currently into_tuple only works on single Select queries. This leads to inconsistencies between the different query types and as such it should be extended to support the SelectTwo and SelectTwoMany queries.

Code like this should work

let res = Email::find_by_id(email_id)
        .select_only()
        .find_also_related(Thread)
        .column(thread::Column::Id)
        .into_tuple()
        .one(db)
        .await?;

Proposed Solutions

into_tuple should work the same as it currently does with Select

Current Workarounds

Currently you can query normally and get a struct in return but getting a tuple directly could help reduce code verbosity.

miam-miam avatar Jun 30 '23 17:06 miam-miam

+1 I also need this method because after multiple join associations, I may only be concerned about a few fields.

ilxqx avatar Oct 31 '23 15:10 ilxqx

Maybe into_tuple() and similar methods should be moved into some trait to prevent such inconsistencies in the future?

Expurple avatar Dec 19 '23 20:12 Expurple