Skip to content

Commit 784d756

Browse files
author
Robert Ros
committed
Replaced RunInTransaction with RunInSavepointTransaction
1 parent 716d3e7 commit 784d756

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

src/SQLite.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -855,31 +855,6 @@ public void Commit ()
855855
// Do nothing on a commit with no open transaction
856856
}
857857

858-
859-
/// <summary>
860-
/// Executes <param name="action"> within a transaction and automatically rollsback the transaction
861-
/// if an exception occurs. The exception is rethrown.
862-
/// </summary>
863-
/// <param name="action">
864-
/// The <see cref="Action"/> to perform within a transaction. <param name="action"> can contain any number
865-
/// of operations on the connection but should never call <see cref="BeginTransaction"/>,
866-
/// <see cref="Rollback"/>, or <see cref="Commit"/>.
867-
/// </param>
868-
public void RunInTransaction (Action action)
869-
{
870-
if (_trasactionDepth != 0) {
871-
throw new InvalidOperationException ("The connection must not already be in a transaction when RunInTransaction is called");
872-
}
873-
try {
874-
BeginTransaction ();
875-
action ();
876-
Commit ();
877-
} catch (Exception) {
878-
Rollback ();
879-
throw;
880-
}
881-
}
882-
883858
/// <summary>
884859
/// Executes <param name="action"> within a (possibly nested) transaction by wrapping it in a SAVEPOINT. If an
885860
/// exception occurs the whole transaction is rolled back, not just the current savepoint. The exception
@@ -890,7 +865,7 @@ public void RunInTransaction (Action action)
890865
/// of operations on the connection but should never call <see cref="BeginTransaction"/> or
891866
/// <see cref="Commit"/>.
892867
/// </param>
893-
public void RunInSavepointTransaction (Action action)
868+
public void RunInTransaction (Action action)
894869
{
895870
try {
896871
var savePoint = SaveTransactionPoint ();

tests/TransactionTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void TearDown()
6363
[Test]
6464
public void SuccessfulSavepointTransaction()
6565
{
66-
db.RunInSavepointTransaction(() => {
66+
db.RunInTransaction(() => {
6767
db.Delete(testObjects[0]);
6868
db.Delete(testObjects[1]);
6969
db.Insert(new TestObj());
@@ -76,7 +76,7 @@ public void SuccessfulSavepointTransaction()
7676
public void FailSavepointTransaction()
7777
{
7878
try {
79-
db.RunInSavepointTransaction(() => {
79+
db.RunInTransaction(() => {
8080
db.Delete(testObjects[0]);
8181

8282
throw new TransactionTestException();
@@ -91,10 +91,10 @@ public void FailSavepointTransaction()
9191
[Test]
9292
public void SuccessfulNestedSavepointTransaction()
9393
{
94-
db.RunInSavepointTransaction(() => {
94+
db.RunInTransaction(() => {
9595
db.Delete(testObjects[0]);
9696

97-
db.RunInSavepointTransaction(() => {
97+
db.RunInTransaction(() => {
9898
db.Delete(testObjects[1]);
9999
});
100100
});
@@ -106,10 +106,10 @@ public void SuccessfulNestedSavepointTransaction()
106106
public void FailNestedSavepointTransaction()
107107
{
108108
try {
109-
db.RunInSavepointTransaction(() => {
109+
db.RunInTransaction(() => {
110110
db.Delete(testObjects[0]);
111111

112-
db.RunInSavepointTransaction(() => {
112+
db.RunInTransaction(() => {
113113
db.Delete(testObjects[1]);
114114

115115
throw new TransactionTestException();

0 commit comments

Comments
 (0)