mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
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.
This commit is contained in:
@@ -113,7 +113,7 @@ impl Sql {
|
||||
self.with_conn(|conn| conn.execute(sql, params).map_err(Into::into))
|
||||
}
|
||||
|
||||
fn with_conn<T, G>(&self, g: G) -> Result<T>
|
||||
pub fn with_conn<T, G>(&self, g: G) -> Result<T>
|
||||
where
|
||||
G: FnOnce(&mut Connection) -> Result<T>,
|
||||
{
|
||||
@@ -360,7 +360,7 @@ impl Sql {
|
||||
.and_then(|r| r.parse().ok())
|
||||
}
|
||||
|
||||
fn start_stmt(&self, stmt: impl AsRef<str>) {
|
||||
pub fn start_stmt(&self, stmt: impl AsRef<str>) {
|
||||
if let Some(query) = self.in_use.get_cloned() {
|
||||
let bt = backtrace::Backtrace::new();
|
||||
eprintln!("old query: {}", query);
|
||||
|
||||
Reference in New Issue
Block a user