From afebf513302b17a66da6b04a1e31b57bcb36f99b Mon Sep 17 00:00:00 2001 From: AbelHristodor Date: Mon, 5 Feb 2024 16:27:54 +0100 Subject: [PATCH] fix: added stored procedures --- Cargo.lock | 2 +- Cargo.toml | 2 +- pgcronner.pyi | 14 +++++++------- src/utils.rs | 7 +++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff2653f..648a422 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -466,7 +466,7 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pgcronner" -version = "0.1.9" +version = "0.1.12" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 582d8c1..d2a8eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pgcronner" -version = "0.1.9" +version = "0.1.13" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/pgcronner.pyi b/pgcronner.pyi index 69ab434..4283f16 100644 --- a/pgcronner.pyi +++ b/pgcronner.pyi @@ -39,7 +39,7 @@ class PgCronner(object): Get all jobs in the table :return: List of jobs as dicts - :throws: OSError + :throws: OSError, ValueError """ def one(self, jobname: str) -> Optional[Dict[str, str]]: @@ -49,7 +49,7 @@ class PgCronner(object): :param jobname: job name :return: Job instance or None, as dict - :throws: OsError + :throws: OsError, ValueError """ def add(self, job: Job) -> bool: @@ -59,7 +59,7 @@ class PgCronner(object): :param job: Job instance :return: True if successful - :throws: OsError + :throws: OsError, ValueError """ def remove(self, jobname: str) -> bool: @@ -69,7 +69,7 @@ class PgCronner(object): :param jobname: job name :return: True if successful - :throws: OsError + :throws: OsError, ValueError """ def refresh(self) -> bool: @@ -78,7 +78,7 @@ class PgCronner(object): :return: True if successful - :throws: OsError + :throws: OsError, ValueError """ def clear(self) -> bool: @@ -87,7 +87,7 @@ class PgCronner(object): :return: True if successful - :throws: OsError + :throws: OsError, ValueError """ @@ -97,6 +97,6 @@ class PgCronner(object): :return: True if successful - :throws: OsError + :throws: OsError, ValueError """ diff --git a/src/utils.rs b/src/utils.rs index 3f5b3b0..40a4fe2 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -31,11 +31,10 @@ pub fn create_stored_procedure( ) -> Result<(), DbError> { match client.query( &format!( - "CREATE OR REPLACE FUNCTION {}() RETURNS void AS $$ - BEGIN + "CREATE OR REPLACE PROCEDURE {}() LANGUAGE SQL + BEGIN ATOMIC {} - END; - $$ LANGUAGE plpgsql;", + END;", name, source ), &[],