Skip to content

Commit

Permalink
test for FromRow -> skip attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
grgi committed Feb 14, 2023
1 parent 9699cfb commit 70d9bcb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/postgres/derives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,34 @@ async fn test_flatten() -> anyhow::Result<()> {

Ok(())
}


#[cfg(feature = "macros")]
#[sqlx_macros::test]
async fn test_skip() -> anyhow::Result<()> {
#[derive(Debug, Default, sqlx::FromRow)]
struct AccountDefault {
default: Option<i32>,
}

#[derive(Debug, sqlx::FromRow)]
struct AccountKeyword {
id: i32,
#[sqlx(skip)]
default: AccountDefault,
}

let mut conn = new::<Postgres>().await?;

let account: AccountKeyword = sqlx::query_as(
r#"SELECT * from (VALUES (1)) accounts("id")"#,
)
.fetch_one(&mut conn)
.await?;
println!("{:?}", account);

assert_eq!(1, account.id);
assert_eq!(None, account.default.default);

Ok(())
}

0 comments on commit 70d9bcb

Please sign in to comment.