mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Merge pull request #470 from rainhead/master
Derive Debug for Transaction
This commit is contained in:
commit
dbc48fcde9
@ -11,7 +11,7 @@ pub enum TransactionBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Options for how a Transaction or Savepoint should behave when it is dropped.
|
/// Options for how a Transaction or Savepoint should behave when it is dropped.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum DropBehavior {
|
pub enum DropBehavior {
|
||||||
/// Roll back the changes. This is the default.
|
/// Roll back the changes. This is the default.
|
||||||
Rollback,
|
Rollback,
|
||||||
@ -50,6 +50,7 @@ pub enum DropBehavior {
|
|||||||
/// tx.commit()
|
/// tx.commit()
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Transaction<'conn> {
|
pub struct Transaction<'conn> {
|
||||||
conn: &'conn Connection,
|
conn: &'conn Connection,
|
||||||
drop_behavior: DropBehavior,
|
drop_behavior: DropBehavior,
|
||||||
@ -555,6 +556,16 @@ mod test {
|
|||||||
assert_current_sum(8, &db);
|
assert_current_sum(8, &db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rc() {
|
||||||
|
use std::rc::Rc;
|
||||||
|
let mut conn = Connection::open_in_memory().unwrap();
|
||||||
|
let rc_txn = Rc::new(conn.transaction().unwrap());
|
||||||
|
|
||||||
|
// This will compile only if Transaction is Debug
|
||||||
|
Rc::try_unwrap(rc_txn).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
fn insert(x: i32, conn: &Connection) {
|
fn insert(x: i32, conn: &Connection) {
|
||||||
conn.execute("INSERT INTO foo VALUES(?)", &[x]).unwrap();
|
conn.execute("INSERT INTO foo VALUES(?)", &[x]).unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user