Support "Nest" for `DerivePartialModel` and `FromQueryResult`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 735
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the DerivePartialModel and FromQueryResult derive macros, then read how PartialModelTrait and PrimaryKeyTrait are defined and how SelectTwoMany::all_partial_model consolidates results. The issue is done when a field marked with the proposed flatten argument can represent a nested type implementing the required traits and supports the described primary-key use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100