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

Can not combine find_related and find_also_related #2473

Open
georgeboot opened this issue Jan 13, 2025 · 0 comments
Open

Can not combine find_related and find_also_related #2473

georgeboot opened this issue Jan 13, 2025 · 0 comments

Comments

@georgeboot
Copy link

georgeboot commented Jan 13, 2025

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 georgeboot changed the title Can not combine Can not combine find_related and find_also_related Jan 13, 2025
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