Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DuckDB.NET.Data/DuckDBTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public class DuckDBTransaction : DbTransaction

public override IsolationLevel IsolationLevel { get; }

public override bool SupportsSavepoints => false;

public override void Release(string savepointName) => throw new NotSupportedException();

public DuckDBTransaction(DuckDBConnection connection, IsolationLevel isolationLevel)
{
this.connection = connection;
Expand Down
22 changes: 21 additions & 1 deletion DuckDB.NET.Test/TransactionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ public void RollbackTransactionTwiceTest()
}
}

[Fact]
public async Task SavepointsAreNotSupportedTest()
{
using var transaction = Connection.BeginTransaction();

transaction.SupportsSavepoints.Should().BeFalse();
transaction.Invoking(tr => tr.Save("savepoint"))
.Should().Throw<NotSupportedException>();
transaction.Invoking(tr => tr.Rollback("savepoint"))
.Should().Throw<NotSupportedException>();
transaction.Invoking(tr => tr.Release("savepoint"))
.Should().Throw<NotSupportedException>();
await transaction.Invoking(async tr => await tr.SaveAsync("savepoint"))
.Should().ThrowAsync<NotSupportedException>();
await transaction.Invoking(async tr => await tr.RollbackAsync("savepoint"))
.Should().ThrowAsync<NotSupportedException>();
await transaction.Invoking(async tr => await tr.ReleaseAsync("savepoint"))
.Should().ThrowAsync<NotSupportedException>();
}

[Fact]
public void CommitAndRollbackTransactionTest()
{
Expand Down Expand Up @@ -136,7 +156,7 @@ public void AbortedTransactionTest()
tx2.Invoking(tx2 => tx2.Rollback()).Should().Throw<InvalidOperationException>();
tx2.Invoking(tx2 => tx2.Dispose()).Should().NotThrow();

Connection.Invoking(conn => conn.BeginTransaction()).Should().NotThrow();
Connection.Invoking(conn => conn.BeginTransaction().Dispose()).Should().NotThrow();
}
}
}
Loading