diff --git a/src/macros.rs b/src/macros.rs index 35f911fd4e..1556355176 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -94,7 +94,7 @@ macro_rules! query ( } macro_result!() }); - ($query:literal, $($args:expr),*) => ({ + ($query:literal, $($args:expr),*$(,)?) => ({ #[macro_use] mod _macro_result { $crate::sqlx_macros::query!($query, $($args),*); @@ -155,7 +155,7 @@ macro_rules! query_file ( } macro_result!() }); - ($query:literal, $($args:expr),*) => (#[allow(dead_code)]{ + ($query:literal, $($args:expr),*$(,)?) => (#[allow(dead_code)]{ #[macro_use] mod _macro_result { $crate::sqlx_macros::query_file!($query, $($args),*); @@ -221,7 +221,7 @@ macro_rules! query_as ( } macro_result!() }); - ($out_struct:path, $query:literal, $($args:expr),*) => (#[allow(dead_code)] { + ($out_struct:path, $query:literal, $($args:expr),*$(,)?) => (#[allow(dead_code)] { #[macro_use] mod _macro_result { $crate::sqlx_macros::query_as!($out_struct, $query, $($args),*); @@ -272,7 +272,7 @@ macro_rules! query_file_as ( } macro_result!() }); - ($out_struct:path, $query:literal, $($args:expr),*) => (#[allow(dead_code)] { + ($out_struct:path, $query:literal, $($args:expr),*$(,)?) => (#[allow(dead_code)] { #[macro_use] mod _macro_result { $crate::sqlx_macros::query_file_as!($out_struct, $query, $($args),*); diff --git a/tests/postgres-macros.rs b/tests/postgres-macros.rs index 82378a5abe..eb1d8f55b8 100644 --- a/tests/postgres-macros.rs +++ b/tests/postgres-macros.rs @@ -7,7 +7,7 @@ async fn test_query() -> anyhow::Result<()> { let account = sqlx::query!( "SELECT * from (VALUES (1, 'Herp Derpinson')) accounts(id, name) where id = $1", - 1i32 + 1i32, ) .fetch_one(&mut conn) .await?; @@ -34,7 +34,7 @@ async fn test_no_result() -> anyhow::Result<()> { async fn _file() -> anyhow::Result<()> { let mut conn = connect().await?; - let account = sqlx::query_file!("tests/test-query.sql") + let account = sqlx::query_file!("tests/test-query.sql",) .fetch_one(&mut conn) .await?; @@ -56,7 +56,7 @@ async fn test_query_as() -> anyhow::Result<()> { let account = sqlx::query_as!( Account, - "SELECT * from (VALUES (1, null)) accounts(id, name)" + "SELECT * from (VALUES (1, null)) accounts(id, name)", ) .fetch_one(&mut conn) .await?; @@ -99,7 +99,7 @@ async fn test_query_as_raw() -> anyhow::Result<()> { async fn test_query_file_as() -> anyhow::Result<()> { let mut conn = connect().await?; - let account = sqlx::query_file_as!(Account, "tests/test-query.sql") + let account = sqlx::query_file_as!(Account, "tests/test-query.sql",) .fetch_one(&mut conn) .await?;