mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-17 18:04:37 +00:00
feat: support calling PostgreSQL procedures with the macros
Fixes #1449 (I think). I verified that the code fixes the new test. I used INOUT in setup.sql because older versions of Postgres don't support OUT parameters.
This commit is contained in:
committed by
Austin Bonander
parent
bb2baf2183
commit
1ff6a2ac94
@@ -96,6 +96,19 @@ async fn test_void() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_call_procedure() -> anyhow::Result<()> {
|
||||
let mut conn = new::<Postgres>().await?;
|
||||
|
||||
let row = sqlx::query!(r#"CALL forty_two(null)"#)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
assert_eq!(row.forty_two, Some(42));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_query_file() -> anyhow::Result<()> {
|
||||
let mut conn = new::<Postgres>().await?;
|
||||
|
||||
@@ -41,3 +41,6 @@ CREATE TABLE products (
|
||||
name TEXT,
|
||||
price NUMERIC CHECK (price > 0)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE PROCEDURE forty_two(INOUT forty_two INT = NULL)
|
||||
LANGUAGE plpgsql AS 'begin forty_two := 42; end;';
|
||||
|
||||
Reference in New Issue
Block a user