mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 07:21:08 +00:00
test for FromRow -> skip attribute
This commit is contained in:
parent
665b859645
commit
03de69bcaa
@ -649,3 +649,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(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user