From 784964efad61542b8e74c65308aca3cdcb4b2786 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 15 Feb 2020 16:28:46 +0300 Subject: [PATCH] Make sql::with_conn and sql::start_stmt public Existing public methods that use these functions, like sql::execute, are only suitable for executing a single statement. Sometimes it is useful to execute multiple statements within one connection, for example to begin a transaction, execute mutliple SELECT and INSERT queries and commit or rollback the whole transaction. --- src/sql.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql.rs b/src/sql.rs index be0641228..ea073ee5d 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -113,7 +113,7 @@ impl Sql { self.with_conn(|conn| conn.execute(sql, params).map_err(Into::into)) } - fn with_conn(&self, g: G) -> Result + pub fn with_conn(&self, g: G) -> Result where G: FnOnce(&mut Connection) -> Result, { @@ -360,7 +360,7 @@ impl Sql { .and_then(|r| r.parse().ok()) } - fn start_stmt(&self, stmt: impl AsRef) { + pub fn start_stmt(&self, stmt: impl AsRef) { if let Some(query) = self.in_use.get_cloned() { let bt = backtrace::Backtrace::new(); eprintln!("old query: {}", query);