• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / DuckDB.NET / 21786556530

07 Feb 2026 08:39PM UTC coverage: 89.155% (-0.07%) from 89.223%
21786556530

push

github

Giorgi
Added support for clearing in-progress adapter

Requires DuckDB 1.5

1199 of 1393 branches covered (86.07%)

Branch coverage included in aggregate %.

6 of 8 new or added lines in 1 file covered. (75.0%)

193 existing lines in 43 files now uncovered.

2336 of 2572 relevant lines covered (90.82%)

557295.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/DuckDB.NET.Data/DuckDBTransaction.cs
1
namespace DuckDB.NET.Data;
2

3
public class DuckDBTransaction : DbTransaction
4
{
5
    private bool finished = false;
6
    private readonly DuckDBConnection connection;
7

8
    protected override DbConnection DbConnection => connection;
3✔
9

10
    public override IsolationLevel IsolationLevel { get; }
3✔
11

12
    public DuckDBTransaction(DuckDBConnection connection, IsolationLevel isolationLevel)
24✔
13
    {
14
        this.connection = connection;
24✔
15
        IsolationLevel = isolationLevel;
24✔
16

17
        if (isolationLevel != IsolationLevel.Snapshot && isolationLevel != IsolationLevel.Unspecified)
24✔
18
        {
19
            throw new ArgumentException($"Unsupported isolation level: {isolationLevel}", nameof(isolationLevel));
3✔
20
        }
21

22
        this.connection.ExecuteNonQuery("BEGIN TRANSACTION;");
21✔
23
    }
21✔
24

25
    public override void Commit() => FinishTransaction("COMMIT;");
15✔
26

27
    public override void Rollback() => FinishTransaction("ROLLBACK");
18✔
28

29
    private void FinishTransaction(string finalizer)
30
    {
31
        if (finished)
33✔
32
        {
33
            throw new InvalidOperationException("Transaction has already been finished.");
12✔
34
        }
35

36
        try
37
        {
38
            connection.ExecuteNonQuery(finalizer);
21✔
39
            Cleanup();
21✔
40
        }
21✔
41
        // If something goes wrong with the transaction, to match the
42
        // transaction's internal duckdb state it should still be considered
43
        // finished and should no longer be used
UNCOV
44
        catch (DuckDBException ex) when (ex.ErrorType == Native.DuckDBErrorType.Transaction)
×
45
        {
UNCOV
46
            Cleanup();
×
UNCOV
47
            throw;
×
48
        }
49

50
        void Cleanup()
51
        {
52
            connection.Transaction = null;
21✔
53
            finished = true;
21✔
54
        }
21✔
55
    }
21✔
56

57
    protected override void Dispose(bool disposing)
58
    {
59
        base.Dispose(disposing);
21✔
60

61
        if (disposing && !finished && connection.IsOpen())
21✔
62
        {
63
            Rollback();
6✔
64
        }
65
    }
21✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc