mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-27 03:51:38 +08:00
Add DropBehavior::Panic to enforce intentional commit or rollback.
This commit is contained in:
parent
402d5340d5
commit
2a03c1ad4d
@ -26,6 +26,9 @@ pub enum DropBehavior {
|
|||||||
/// Do not commit or roll back changes - this will leave the transaction or savepoint
|
/// Do not commit or roll back changes - this will leave the transaction or savepoint
|
||||||
/// open, so should be used with care.
|
/// open, so should be used with care.
|
||||||
Ignore,
|
Ignore,
|
||||||
|
|
||||||
|
/// Panic. Used to enforce intentional behavior during development.
|
||||||
|
Panic,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Old name for `Transaction`. `SqliteTransaction` is deprecated.
|
/// Old name for `Transaction`. `SqliteTransaction` is deprecated.
|
||||||
@ -192,6 +195,7 @@ impl<'conn> Transaction<'conn> {
|
|||||||
DropBehavior::Commit => self.commit_(),
|
DropBehavior::Commit => self.commit_(),
|
||||||
DropBehavior::Rollback => self.rollback_(),
|
DropBehavior::Rollback => self.rollback_(),
|
||||||
DropBehavior::Ignore => Ok(()),
|
DropBehavior::Ignore => Ok(()),
|
||||||
|
DropBehavior::Panic => panic!("Transaction dropped unexpectedly."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,6 +307,7 @@ impl<'conn> Savepoint<'conn> {
|
|||||||
DropBehavior::Commit => self.commit_(),
|
DropBehavior::Commit => self.commit_(),
|
||||||
DropBehavior::Rollback => self.rollback(),
|
DropBehavior::Rollback => self.rollback(),
|
||||||
DropBehavior::Ignore => Ok(()),
|
DropBehavior::Ignore => Ok(()),
|
||||||
|
DropBehavior::Panic => panic!("Savepoint dropped unexpectedly."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user