mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
fix(macros): fix macros for Postgres
This commit is contained in:
parent
e3dbd58bf2
commit
bddb2e560f
5 changed files with 11 additions and 4 deletions
|
@ -144,3 +144,8 @@ required-features = [ "postgres" ]
|
||||||
name = "postgres-describe"
|
name = "postgres-describe"
|
||||||
path = "tests/postgres/describe.rs"
|
path = "tests/postgres/describe.rs"
|
||||||
required-features = [ "postgres" ]
|
required-features = [ "postgres" ]
|
||||||
|
|
||||||
|
[[test]]
|
||||||
|
name = "postgres-macros"
|
||||||
|
path = "tests/postgres/macros.rs"
|
||||||
|
required-features = [ "postgres", "macros" ]
|
||||||
|
|
|
@ -183,7 +183,7 @@ where
|
||||||
let sql = &input.src;
|
let sql = &input.src;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
sqlx::query::<#db_path>(#sql).bind_all(#query_args)
|
sqlx::query_with::<#db_path, _>(#sql, #query_args)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let columns = output::columns_to_rust::<DB>(&data.describe)?;
|
let columns = output::columns_to_rust::<DB>(&data.describe)?;
|
||||||
|
|
|
@ -119,7 +119,7 @@ pub fn quote_query_as<DB: DatabaseExt>(
|
||||||
let sql = &input.src;
|
let sql = &input.src;
|
||||||
|
|
||||||
quote! {
|
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::Row as _;
|
||||||
use sqlx::result_ext::ResultExt as _;
|
use sqlx::result_ext::ResultExt as _;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ async fn test_text_var_char_char_n() -> anyhow::Result<()> {
|
||||||
async fn _file() -> anyhow::Result<()> {
|
async fn _file() -> anyhow::Result<()> {
|
||||||
let mut conn = new::<Postgres>().await?;
|
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)
|
.fetch_one(&mut conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ async fn test_query_as_raw() -> anyhow::Result<()> {
|
||||||
async fn test_query_file_as() -> anyhow::Result<()> {
|
async fn test_query_file_as() -> anyhow::Result<()> {
|
||||||
let mut conn = new::<Postgres>().await?;
|
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)
|
.fetch_one(&mut conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
1
tests/postgres/test-query.sql
Normal file
1
tests/postgres/test-query.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SELECT * from (VALUES (1, null)) accounts(id, name)
|
Loading…
Reference in a new issue