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

Giorgi / DuckDB.NET / 12084884944

29 Nov 2024 12:37PM UTC coverage: 89.839% (-0.04%) from 89.881%
12084884944

push

github

Giorgi
Rename conflicting table function

1055 of 1209 branches covered (87.26%)

Branch coverage included in aggregate %.

2075 of 2275 relevant lines covered (91.21%)

824654.22 hits per line

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

84.21
/DuckDB.NET.Bindings/DuckDBWrapperObjects.cs
1
using Microsoft.Win32.SafeHandles;
2
using System;
3
using System.Runtime.CompilerServices;
4

5
namespace DuckDB.NET.Native;
6

7
public class DuckDBDatabase() : SafeHandleZeroOrMinusOneIsInvalid(true)
43,162✔
8
{
9
    protected override bool ReleaseHandle()
10
    {
11
        NativeMethods.Startup.DuckDBClose(out handle);
43,158✔
12
        return true;
43,158✔
13
    }
14
}
15

16
public class DuckDBNativeConnection() : SafeHandleZeroOrMinusOneIsInvalid(true)
64,926✔
17
{
18
    protected override bool ReleaseHandle()
19
    {
20
        NativeMethods.Startup.DuckDBDisconnect(out handle);
64,922✔
21
        return true;
64,922✔
22
    }
23

24
    public void Interrupt()
25
    {
26
        NativeMethods.Startup.DuckDBInterrupt(this);
3✔
27
    }
3✔
28
}
29

30
public class DuckDBPreparedStatement() : SafeHandleZeroOrMinusOneIsInvalid(true)
219,354✔
31
{
32
    protected override bool ReleaseHandle()
33
    {
34
        NativeMethods.PreparedStatements.DuckDBDestroyPrepare(out handle);
219,341✔
35
        return true;
219,341✔
36
    }
37
}
38

39
public class DuckDBConfig() : SafeHandleZeroOrMinusOneIsInvalid(true)
43,162✔
40
{
41
    protected override bool ReleaseHandle()
42
    {
43
        NativeMethods.Configuration.DuckDBDestroyConfig(out handle);
43,162✔
44
        return true;
43,162✔
45
    }
46
}
47

48
public class DuckDBAppender() : SafeHandleZeroOrMinusOneIsInvalid(true)
183✔
49
{
50
    protected override bool ReleaseHandle()
51
    {
52
        return NativeMethods.Appender.DuckDBDestroyAppender(out handle) == DuckDBState.Success;
183✔
53
    }
54
}
55

56
public class DuckDBExtractedStatements() : SafeHandleZeroOrMinusOneIsInvalid(true)
219,246✔
57
{
58
    protected override bool ReleaseHandle()
59
    {
60
        NativeMethods.ExtractStatements.DuckDBDestroyExtracted(out handle);
219,233✔
61

62
        return true;
219,233✔
63
    }
64
}
65

66
public class DuckDBLogicalType() : SafeHandleZeroOrMinusOneIsInvalid(true)
90,149✔
67
{
68
    protected override bool ReleaseHandle()
69
    {
70
        NativeMethods.LogicalType.DuckDBDestroyLogicalType(out handle);
89,594✔
71
        return true;
89,594✔
72
    }
73
}
74

75
public class DuckDBDataChunk : SafeHandleZeroOrMinusOneIsInvalid
76
{
77
    public DuckDBDataChunk() : base(true)
64,689✔
78
    {
79
    }
64,689✔
80

81
    public DuckDBDataChunk(IntPtr chunk) : base(false)
117✔
82
    {
83
        SetHandle(chunk);
117✔
84
    }
117✔
85

86
    protected override bool ReleaseHandle()
87
    {
88
        NativeMethods.DataChunks.DuckDBDestroyDataChunk(out handle);
64,234✔
89
        return true;
64,234✔
90
    }
91
}
92

93
public class DuckDBValue() : SafeHandleZeroOrMinusOneIsInvalid(true), IDuckDBValueReader
10,367✔
94
{
95
    private DuckDBValue[] childValues = [];
10,367✔
96

97
    protected override bool ReleaseHandle()
98
    {
99
        foreach (var value in childValues)
39,842✔
100
        {
101
            value.Dispose();
9,554✔
102
        }
103
        
104
        NativeMethods.Value.DuckDBDestroyValue(out handle);
10,367✔
105
        return true;
10,367✔
106
    }
107

108
    internal void SetChildValues(DuckDBValue[] values)
109
    {
110
        childValues = values;
396✔
111
    }
396✔
112

113
    public bool IsNull() => NativeMethods.Value.DuckDBIsNullValue(this);
3✔
114

115
    public T GetValue<T>()
116
    {
117
        var logicalType = NativeMethods.Value.DuckDBGetValueType(this);
51✔
118

119
        //Logical type is part of the duckdb_value object and it shouldn't be released separately
120
        //It will get released when the duckdb_value object is destroyed below.
121
        var add = false;
51✔
122
        logicalType.DangerousAddRef(ref add);
51✔
123

124
        var duckDBType = NativeMethods.LogicalType.DuckDBGetTypeId(logicalType);
51✔
125

126
        return duckDBType switch
51!
127
        {
51✔
128
            DuckDBType.Boolean => Cast(NativeMethods.Value.DuckDBGetBool(this)),
3✔
129

51✔
130
            DuckDBType.TinyInt => Cast(NativeMethods.Value.DuckDBGetInt8(this)),
3✔
131
            DuckDBType.SmallInt => Cast(NativeMethods.Value.DuckDBGetInt16(this)),
3✔
132
            DuckDBType.Integer => Cast(NativeMethods.Value.DuckDBGetInt32(this)),
3✔
133
            DuckDBType.BigInt => Cast(NativeMethods.Value.DuckDBGetInt64(this)),
3✔
134

51✔
135
            DuckDBType.UnsignedTinyInt => Cast(NativeMethods.Value.DuckDBGetUInt8(this)),
3✔
136
            DuckDBType.UnsignedSmallInt => Cast(NativeMethods.Value.DuckDBGetUInt16(this)),
3✔
137
            DuckDBType.UnsignedInteger => Cast(NativeMethods.Value.DuckDBGetUInt32(this)),
3✔
138
            DuckDBType.UnsignedBigInt => Cast(NativeMethods.Value.DuckDBGetUInt64(this)),
3✔
139

51✔
140
            DuckDBType.Float => Cast(NativeMethods.Value.DuckDBGetFloat(this)),
3✔
141
            DuckDBType.Double => Cast(NativeMethods.Value.DuckDBGetDouble(this)),
3✔
142
            
51✔
143
            DuckDBType.Decimal => Cast(decimal.Parse(NativeMethods.Value.DuckDBGetVarchar(this))),
3✔
144
            DuckDBType.Uuid => Cast(new Guid(NativeMethods.Value.DuckDBGetVarchar(this))),
3✔
145
            
51✔
146
            DuckDBType.HugeInt => Cast(NativeMethods.Value.DuckDBGetHugeInt(this).ToBigInteger()),
3✔
147
            DuckDBType.UnsignedHugeInt => Cast(NativeMethods.Value.DuckDBGetUHugeInt(this).ToBigInteger()),
×
148
            
51✔
149
            DuckDBType.Varchar => Cast(NativeMethods.Value.DuckDBGetVarchar(this)),
3✔
150
            
51✔
151
            //DuckDBType.Date => expr,
51✔
152
            //DuckDBType.Time => expr,
51✔
153
            //DuckDBType.TimeTz => expr,
51✔
154
            DuckDBType.Interval => Cast((TimeSpan)NativeMethods.Value.DuckDBGetInterval(this)),
3✔
155
            DuckDBType.Timestamp => Cast(NativeMethods.DateTimeHelpers.DuckDBFromTimestamp(NativeMethods.Value.DuckDBGetTimestamp(this)).ToDateTime()),
3✔
156
            //DuckDBType.TimestampS => expr,
51✔
157
            //DuckDBType.TimestampMs => expr,
51✔
158
            //DuckDBType.TimestampNs => expr,
51✔
159
            //DuckDBType.TimestampTz => expr,
51✔
160
            _ => throw new NotImplementedException($"Cannot read value of type {typeof(T).FullName}")
×
161
        };
51✔
162

163
        T Cast<TSource>(TSource value) => Unsafe.As<TSource, T>(ref value);
51✔
164
    }
165
}
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