fix(macros): fix macros for Postgres

This commit is contained in:
Austin Bonander 2020-06-05 20:28:21 -07:00
parent e3dbd58bf2
commit bddb2e560f
No known key found for this signature in database
GPG key ID: 4E7DA63E66AFC37E
5 changed files with 11 additions and 4 deletions

View file

@ -144,3 +144,8 @@ required-features = [ "postgres" ]
name = "postgres-describe"
path = "tests/postgres/describe.rs"
required-features = [ "postgres" ]
[[test]]
name = "postgres-macros"
path = "tests/postgres/macros.rs"
required-features = [ "postgres", "macros" ]

View file

@ -183,7 +183,7 @@ where
let sql = &input.src;
quote! {
sqlx::query::<#db_path>(#sql).bind_all(#query_args)
sqlx::query_with::<#db_path, _>(#sql, #query_args)
}
} else {
let columns = output::columns_to_rust::<DB>(&data.describe)?;

View file

@ -119,7 +119,7 @@ pub fn quote_query_as<DB: DatabaseExt>(
let sql = &input.src;
quote! {
sqlx::query_with::<#db_path>(#sql, #bind_args).try_map(|row: #row_path| {
sqlx::query_with::<#db_path, _>(#sql, #bind_args).try_map(|row: #row_path| {
use sqlx::Row as _;
use sqlx::result_ext::ResultExt as _;

View file

@ -65,7 +65,8 @@ async fn test_text_var_char_char_n() -> anyhow::Result<()> {
async fn _file() -> anyhow::Result<()> {
let mut conn = new::<Postgres>().await?;
let account = sqlx::query_file!("tests/test-query.sql",)
// keep trailing comma as a test
let account = sqlx::query_file!("tests/postgres/test-query.sql",)
.fetch_one(&mut conn)
.await?;
@ -129,7 +130,7 @@ async fn test_query_as_raw() -> anyhow::Result<()> {
async fn test_query_file_as() -> anyhow::Result<()> {
let mut conn = new::<Postgres>().await?;
let account = sqlx::query_file_as!(Account, "tests/test-query.sql",)
let account = sqlx::query_file_as!(Account, "tests/postgres/test-query.sql",)
.fetch_one(&mut conn)
.await?;

View file

@ -0,0 +1 @@
SELECT * from (VALUES (1, null)) accounts(id, name)