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

Can not combine find_related and find_also_related

Open georgeboot opened this issue 9 months ago • 0 comments

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

georgeboot avatar Jan 13 '25 12:01 georgeboot