Can not combine find_related and find_also_related
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Description
When loading a 1:1 relation from a model, and also loading it's related model, an error is thrown: cannot apply alias for expr other than Column or AsEnum
let line_item: line_item:Model = line_item::Entity::find().one(&ctx.db).await?;
let (order, customer): (order::Model, Option<customer::Model>) = line_item.find_related(order::Entity)
.find_also_related(customer::Entity)
.one(&ctx.db).await?;
My assumption is that this fails as it's finding the related customer for the line_item (not the order!) and that line_item and customer are not related.
Expected Behavior
The expected behaviour is that this would work, and that the order is loaded, and the customer the order is linked to.
Actual Behavior
An error is thrown: cannot apply alias for expr other than Column or AsEnum
Versions
Tested on 1.1.0
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 reproducing the Rust example with find_related and find_also_related, then trace the relation-loading and aliasing path that produces "cannot apply alias for expr other than Column or AsEnum." Confirm whether the chained query follows the order relation to customer, and add coverage showing the expected order and customer results once fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100