concat test

This commit is contained in:
Mike Ledger 2020-07-04 08:08:34 +10:00 committed by Austin Bonander
parent ee106286a0
commit 03fcfc8562

View file

@ -16,6 +16,27 @@ async fn macro_select() -> anyhow::Result<()> {
Ok(())
}
macro_rules! gen_macro_select_concats {
($param:literal) => {
#[sqlx_macros::test]
async fn macro_select_concat_single() -> anyhow::Result<()> {
let mut conn = new::<Sqlite>().await?;
let account = sqlx::query!("select " + $param + " from accounts where id = 1")
.fetch_one(&mut conn)
.await?;
assert_eq!(1, account.id);
assert_eq!("Herp Derpinson", account.name);
assert_eq!(account.is_active, Some(true));
Ok(())
}
}
}
gen_macro_select_concats!("id, name, is_active");
#[sqlx_macros::test]
async fn macro_select_expression() -> anyhow::Result<()> {
let mut conn = new::<Sqlite>().await?;