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

Support "Nest" for DerivePartialModel and FromQueryResult #1715

Open
Goodjooy opened this issue Jun 21, 2023 · 1 comment
Open

Support "Nest" for DerivePartialModel and FromQueryResult #1715

Goodjooy opened this issue Jun 21, 2023 · 1 comment

Comments

@Goodjooy
Copy link
Contributor

Goodjooy commented Jun 21, 2023

Motivation

When I implement the DerivePartialModel I find I can't implement SelectTwoMany::all_partial_model because of no primany key to consolidate result. I think it may can be solved.
If support “Nest”, then we can construct following PartialModel
(I suppose the PrimaryKeyTrait has an associate type PartialModel whitch contain all of its primany key)

#[derive(FromQueryResult, DerivePartialModel)]
struct TwoManyWithPk<E, M>
where
    E: Entity,
    M: PartialModelTrait + FromQueryResult
{
    #[sea_orm(flatten)]
     pk: <<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::PartialModel,
    #[sea_orm(flatten)]
    payload: M
}

That can make consolidate result possible

This is not only advance of Support "Nest" for DerivePartialModel and FromQueryResult. I believe it will useful in many condition.

Proposed Solutions

add derive macro argument flatten for derive macro PartialModelTrait and FromQueryResult , mark specified field became "Nest". this require the type of this field implement PartialModelTrait and FromQueryResult

Current Workarounds

Manual writing PartialModel with each field and cannot using preivous exits PartialModel

@Goodjooy
Copy link
Contributor Author

I am writing the code in the pr #1716

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant