Make the creation of transactions and savepoints take &mut self.

Transactions in SQLite are nested, but the previous API allowed rusqlite
transaction wrappers to be created as "siblings". This resulted in
unexpected (and usually wrong) behavior.
This commit is contained in:
John Gallagher
2016-05-17 19:53:53 -05:00
parent 63e5570ca9
commit 92834951e3
2 changed files with 31 additions and 22 deletions

View File

@@ -237,7 +237,7 @@ impl Connection {
/// # Failure
///
/// Will return `Err` if the underlying SQLite call fails.
pub fn transaction(&self) -> Result<Transaction> {
pub fn transaction(&mut self) -> Result<Transaction> {
Transaction::new(self, TransactionBehavior::Deferred)
}
@@ -248,7 +248,7 @@ impl Connection {
/// # Failure
///
/// Will return `Err` if the underlying SQLite call fails.
pub fn transaction_with_behavior(&self, behavior: TransactionBehavior) -> Result<Transaction> {
pub fn transaction_with_behavior(&mut self, behavior: TransactionBehavior) -> Result<Transaction> {
Transaction::new(self, behavior)
}