• 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

95.52
/DuckDB.NET.Data/Extensions/TypeExtensions.cs
1
using System.Diagnostics.CodeAnalysis;
2

3
namespace DuckDB.NET.Data.Extensions;
4

5
internal static class TypeExtensions
6
{
7
    private static readonly HashSet<Type> FloatingNumericTypes = [typeof(decimal), typeof(float), typeof(double)];
3✔
8

9
    private static readonly HashSet<Type> IntegralNumericTypes =
3✔
10
    [
3✔
11
        typeof(byte), typeof(sbyte),
3✔
12
        typeof(short), typeof(ushort),
3✔
13
        typeof(int), typeof(uint),
3✔
14
        typeof(long), typeof(ulong),
3✔
15
        typeof(BigInteger)
3✔
16
    ];
3✔
17

18
    private static readonly Dictionary<Type, DuckDBType> ClrToDuckDBTypeMap = new()
3✔
19
    {
3✔
20
        { typeof(bool), DuckDBType.Boolean },
3✔
21
        { typeof(sbyte), DuckDBType.TinyInt },
3✔
22
        { typeof(short), DuckDBType.SmallInt },
3✔
23
        { typeof(int), DuckDBType.Integer },
3✔
24
        { typeof(long), DuckDBType.BigInt },
3✔
25
        { typeof(byte), DuckDBType.UnsignedTinyInt },
3✔
26
        { typeof(ushort), DuckDBType.UnsignedSmallInt },
3✔
27
        { typeof(uint), DuckDBType.UnsignedInteger },
3✔
28
        { typeof(ulong), DuckDBType.UnsignedBigInt },
3✔
29
        { typeof(float), DuckDBType.Float },
3✔
30
        { typeof(double), DuckDBType.Double},
3✔
31
        { typeof(Guid), DuckDBType.Uuid},
3✔
32
        { typeof(DateTime), DuckDBType.Timestamp},
3✔
33
        { typeof(TimeSpan), DuckDBType.Interval},
3✔
34
        { typeof(DateOnly), DuckDBType.Date},
3✔
35
        { typeof(TimeOnly), DuckDBType.Time},
3✔
36
        { typeof(DateTimeOffset), DuckDBType.TimestampTz},
3✔
37
        { typeof(BigInteger), DuckDBType.HugeInt},
3✔
38
        { typeof(string), DuckDBType.Varchar},
3✔
39
        { typeof(decimal), DuckDBType.Decimal},
3✔
40
        { typeof(object), DuckDBType.Any},
3✔
41
    };
3✔
42

43
    public static bool IsNull([NotNullWhen(false)] this object? value) => value is null or DBNull;
12,062✔
44

45
    public static (bool isNullableValueType, Type type) IsNullableValueType<T>()
46
    {
47
        var targetType = typeof(T);
5,634,741✔
48

49
        var isNullableValueType = default(T) is null && targetType.IsValueType;
5,634,741✔
50

51
        return (isNullableValueType, targetType);
5,634,741✔
52
    }
53

54
    public static bool IsFloatingNumericType<T>()
55
    {
56
        return FloatingNumericTypes.Contains(typeof(T));
2,795,260✔
57
    }
58

59
    public static bool IsIntegralNumericType<T>()
60
    {
61
        return IntegralNumericTypes.Contains(typeof(T));
2,795,260✔
62
    }
63

64
    public static bool IsNumeric(this Type type)
65
    {
66
        return IntegralNumericTypes.Contains(type) || FloatingNumericTypes.Contains(type);
10,636,680✔
67
    }
68

69
    public static bool AllowsNullValue(this Type type, out bool isNullableValueType, out Type? underlyingType)
70
    {
71
        underlyingType = Nullable.GetUnderlyingType(type);
1,041,002✔
72
        isNullableValueType = underlyingType != null;
1,041,002✔
73

74
        var isNullable = isNullableValueType || !type.IsValueType;
1,041,002✔
75

76
        return isNullable;
307,557✔
77
    }
78

79
    public static DuckDBLogicalType GetLogicalType<T>() => GetLogicalType(typeof(T));
39✔
80

81
    public static DuckDBLogicalType GetLogicalType(this Type type)
82
    {
83
        if (type == typeof(decimal))
225✔
84
        {
85
            return NativeMethods.LogicalType.DuckDBCreateDecimalType(38, 18);
15✔
86
        }
87

88
        if (ClrToDuckDBTypeMap.TryGetValue(type, out var duckDBType))
210!
89
        {
90
            return NativeMethods.LogicalType.DuckDBCreateLogicalType(duckDBType);
210✔
91
        }
92

UNCOV
93
        throw new InvalidOperationException($"Cannot map type {type.FullName} to DuckDBType.");
×
94
    }
95

96
    public static DuckDBType GetDuckDBType(this Type type) => ClrToDuckDBTypeMap.TryGetValue(type, out var duckDBType) ? duckDBType : DuckDBType.Invalid;
27!
97
}
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