Skip to content

Commit

Permalink
feat: add aspirational test
Browse files Browse the repository at this point in the history
  • Loading branch information
jreppnow committed Apr 7, 2024
1 parent 14258a0 commit 656ae5a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/partial_model_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,39 @@ mod runtime {

ctx.delete().await;
}

#[derive(Debug, FromQueryResult, DerivePartialModel)]
#[sea_orm(entity = "bakery::Entity")]
struct WrongBakery {
id: String,
#[sea_orm(from_col = "Name")]
title: String,
}

#[derive(Debug, FromQueryResult, DerivePartialModel)]
#[sea_orm(entity = "cake::Entity")]
struct WrongCake {
id: i32,
name: String,
#[sea_orm(nested)]
bakery: Option<WrongBakery>,
}

#[sea_orm_macros::test]
#[ignore = "This currently does not work, as sqlx does not perform type checking when a column is absent.."]
async fn partial_model_optional_field_but_type_error() {
let ctx = TestContext::new("partial_model_nested_same_table").await;
create_tables(&ctx.db).await.unwrap();

fill_data(&ctx, false).await;

let _: DbErr = cake::Entity::find()
.left_join(bakery::Entity)
.into_partial_model::<WrongCake>()
.one(&ctx.db)
.await
.expect_err("should error instead of returning an empty Option");

ctx.delete().await;
}
}

0 comments on commit 656ae5a

Please sign in to comment.