SeaQL/sea-orm

no column found for name: A_

brsnik opened this issue · 0 comments

Discussed in #2124

Originally posted by brsnik March 1, 2024
This builds the correct query in terms of SQL (from what I can see in the tracer).
However I get error Query Error: no column found for name: A_barcode

MvB::find()
        .find_with_related(MvA)
//        .filter(MvBColumn::Barcode.eq(gtin))
        .stream_partial_model::<DatabaseConnection, MvBSearchModel, MvASearchModel>(&conn)
        .await

My partial models:

#[derive(Debug, FromQueryResult, DerivePartialModel)]
#[sea_orm(entity = "Entity")]
pub struct MvBSearchModel {
    pub barcode: String,
    pub lbl_type: String,
}

and

#[derive(Debug, FromQueryResult, DerivePartialModel)]
#[sea_orm(entity = "Entity")]
pub struct MvASearchModel {
    pub prod_art_id: i32,
    pub prod_art_pub_uuid: Uuid,
    pub lbl_status: String,
}

The query that gets built, again it's correct:

SELECT 
    "mv_b"."barcode", 
    "mv_b"."lbl_type", 
    "mv_a"."prod_art_id", 
    "mv_a"."prod_art_pub_uuid", 
    "mv_a"."lbl_status" 
FROM "products"."mv_b" 
    LEFT JOIN "products"."mv_a" ON "mv_b"."prod_art_pvt_id" = "mv_a"."prod_art_pvt_id" 
ORDER BY "mv_b"."prod_brcd_id" ASC

What is causing this error? Am I doing something wrong?